summaryrefslogtreecommitdiff
path: root/indra/llui/llcommandmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llcommandmanager.cpp')
-rw-r--r--indra/llui/llcommandmanager.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp
index 306b357d6a..6be616b980 100644
--- a/indra/llui/llcommandmanager.cpp
+++ b/indra/llui/llcommandmanager.cpp
@@ -72,9 +72,15 @@ LLCommandManager::LLCommandManager()
LLCommandManager::~LLCommandManager()
{
+ for (CommandVector::iterator cmdIt = mCommands.begin(); cmdIt != mCommands.end(); ++cmdIt)
+ {
+ LLCommand * command = *cmdIt;
+
+ delete command;
+ }
}
-U32 LLCommandManager::count() const
+U32 LLCommandManager::commandCount() const
{
return mCommands.size();
}
@@ -88,20 +94,24 @@ LLCommand * LLCommandManager::getCommand(const std::string& commandName)
{
LLCommand * command_name_match = NULL;
- for (CommandVector::iterator it = mCommands.begin(); it != mCommands.end(); ++it)
+ CommandIndexMap::const_iterator found = mCommandIndices.find(commandName);
+
+ if (found != mCommandIndices.end())
{
- LLCommand * command = *it;
-
- if (command->name() == commandName)
- {
- command_name_match = command;
- break;
- }
+ command_name_match = mCommands[found->second];
}
return command_name_match;
}
+void LLCommandManager::addCommand(LLCommand * command)
+{
+ mCommandIndices[command->name()] = mCommands.size();
+ mCommands.push_back(command);
+
+ llinfos << "Successfully added command: " << command->name() << llendl;
+}
+
//static
bool LLCommandManager::load()
{
@@ -129,9 +139,7 @@ bool LLCommandManager::load()
{
LLCommand * command = new LLCommand(commandParams);
- mgr.mCommands.push_back(command);
-
- llinfos << "Successfully loaded command: " << command->name() << llendl;
+ mgr.addCommand(command);
}
return true;