mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-04 03:55:52 +00:00
Console: Reuse iterator in unregisterCommand()
We can use the result of the first lookup to avoid doing another redundant lookup to perform the erasure. While we're at it, we can use std::string's std::string_view constructor in order to avoid an unnecessary strlen() call.
This commit is contained in:
parent
5d2987588b
commit
7fbdf384de
@ -54,10 +54,15 @@ void Console::registerCommand(std::string_view name, std::string_view helpText,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Console::unregisterCommand(std::string_view name) {
|
void Console::unregisterCommand(std::string_view name) {
|
||||||
std::string lowName = name.data();
|
std::string lowName{name};
|
||||||
athena::utility::tolower(lowName);
|
athena::utility::tolower(lowName);
|
||||||
if (m_commands.find(lowName) != m_commands.end())
|
|
||||||
m_commands.erase(m_commands.find(lowName));
|
const auto iter = m_commands.find(lowName);
|
||||||
|
if (iter == m_commands.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_commands.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Console::executeString(const std::string& str) {
|
void Console::executeString(const std::string& str) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user