Index: code/trunk/src/libraries/core/CommandExecutor.cc
===================================================================
--- code/trunk/src/libraries/core/CommandExecutor.cc	(revision 5929)
+++ code/trunk/src/libraries/core/CommandExecutor.cc	(revision 6417)
@@ -59,5 +59,5 @@
         if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
         {
-            COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << "." << std::endl;
+            COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << '.' << std::endl;
         }
 
@@ -82,5 +82,5 @@
         std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name);
         if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
-            return (*it).second;
+            return it->second;
         else
             return 0;
@@ -96,5 +96,5 @@
         std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name);
         if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end())
-            return (*it).second;
+            return it->second;
         else
             return 0;
@@ -215,5 +215,5 @@
                         CommandExecutor::getEvaluation().state_ = CommandState::Error;
                         AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
-                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".";
+                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + ' ' + GetLocalisation("commandexecutorunknownfirstargument") + '.';
                         return;
                     }
@@ -231,5 +231,5 @@
                     {
                         // It's a shortcut
-                        std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+                        const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first;
                         CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname);
                         if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(0)))
@@ -243,5 +243,5 @@
                         if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
                         {
-                            CommandExecutor::getEvaluation().command_ += " ";
+                            CommandExecutor::getEvaluation().command_ += ' ';
                             CommandExecutor::getEvaluation().bCommandChanged_ = true;
                         }
@@ -251,5 +251,5 @@
                     {
                         // It's a classname
-                        std::string classname = *(*CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()).first;
+                        const std::string& classname = *CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()->first;
                         CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(classname);
                         if (getLowercase(classname) != getLowercase(CommandExecutor::getArgument(0)))
@@ -260,5 +260,5 @@
                         CommandExecutor::getEvaluation().state_ = CommandState::Function;
                         CommandExecutor::getEvaluation().function_ = 0;
-                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " ";
+                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ';
                         // Move on to next case
                     }
@@ -268,5 +268,5 @@
                         CommandExecutor::getEvaluation().state_ = CommandState::Error;
                         AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with");
-                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + " " + CommandExecutor::getArgument(0) + ".";
+                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + ' ' + CommandExecutor::getArgument(0) + '.';
                         return;
                     }
@@ -319,5 +319,5 @@
                         {
                             // It's a function
-                            std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+                            const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first;
                             CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname, CommandExecutor::getEvaluation().functionclass_);
                             if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(1)))
@@ -327,8 +327,8 @@
                             }
                             CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
-                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getEvaluation().function_->getName();
+                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getEvaluation().function_->getName();
                             if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
                             {
-                                CommandExecutor::getEvaluation().command_ += " ";
+                                CommandExecutor::getEvaluation().command_ += ' ';
                                 CommandExecutor::getEvaluation().bCommandChanged_ = true;
                             }
@@ -340,5 +340,5 @@
                             CommandExecutor::getEvaluation().state_ = CommandState::Error;
                             AddLanguageEntry("commandexecutorunknownsecondargumentstart", "has no function starting with");
-                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + " " + GetLocalisation("commandexecutorunknownsecondargumentstart") + " " + CommandExecutor::getArgument(1) + ".";
+                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + GetLocalisation("commandexecutorunknownsecondargumentstart") + ' ' + CommandExecutor::getArgument(1) + '.';
                             return;
                         }
@@ -346,5 +346,5 @@
                         {
                             // There are several possibilities
-                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);
+                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);
                             CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
                             CommandExecutor::getEvaluation().bCommandChanged_ = true;
@@ -386,6 +386,6 @@
                 {
                     // There is exactly one possible argument
-                    CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
-                    CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
+                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
+                    CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString();
                     CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
                     return;
@@ -451,13 +451,13 @@
     }
 
-    std::string CommandExecutor::getArgument(unsigned int index)
+    const std::string& CommandExecutor::getArgument(unsigned int index)
     {
         if (index < (CommandExecutor::getEvaluation().commandTokens_.size()))
             return CommandExecutor::getEvaluation().commandTokens_[index];
         else
-            return "";
-    }
-
-    std::string CommandExecutor::getLastArgument()
+            return BLANKSTRING;
+    }
+
+    const std::string& CommandExecutor::getLastArgument()
     {
         return CommandExecutor::getArgument(CommandExecutor::argumentsGiven() - 1);
@@ -467,9 +467,9 @@
     {
         CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear();
-        std::string lowercase = getLowercase(fragment);
+        const std::string& lowercase = getLowercase(fragment);
         for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapBegin(); it != Identifier::getLowercaseStringIdentifierMapEnd(); ++it)
-            if ((*it).second->hasConsoleCommands())
-                if ((*it).first.find(lowercase) == 0 || fragment == "")
-                    CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+            if (it->second->hasConsoleCommands())
+                if (it->first.find(lowercase) == 0 || fragment.empty())
+                    CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
     }
 
@@ -477,16 +477,16 @@
     {
         CommandExecutor::getEvaluation().listOfPossibleFunctions_.clear();
-        std::string lowercase = getLowercase(fragment);
+        const std::string& lowercase = getLowercase(fragment);
         if (!identifier)
         {
             for (std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)
-                if ((*it).first.find(lowercase) == 0 || fragment == "")
-                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+                if (it->first.find(lowercase) == 0 || fragment.empty())
+                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
         }
         else
         {
             for (std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)
-                if ((*it).first.find(lowercase) == 0 || fragment == "")
-                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+                if (it->first.find(lowercase) == 0 || fragment.empty())
+                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName()));
         }
     }
@@ -497,15 +497,15 @@
 
         CommandExecutor::getEvaluation().listOfPossibleArguments_.clear();
-        std::string lowercase = getLowercase(fragment);
+        const std::string& lowercase = getLowercase(fragment);
         for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
         {
-            if ((*it).lowercaseComparison())
-            {
-                if ((*it).getComparable().find(lowercase) == 0 || fragment == "")
+            if (it->lowercaseComparison())
+            {
+                if (it->getComparable().find(lowercase) == 0 || fragment.empty())
                     CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
             }
             else
             {
-                if ((*it).getComparable().find(fragment) == 0 || fragment == "")
+                if (it->getComparable().find(fragment) == 0 || fragment.empty())
                     CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
             }
@@ -515,8 +515,8 @@
     Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name)
     {
-        std::string lowercase = getLowercase(name);
+        const std::string& lowercase = getLowercase(name);
         std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase);
-        if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
-            return (*it).second;
+        if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && it->second->hasConsoleCommands())
+            return it->second;
 
         return 0;
@@ -525,10 +525,10 @@
     ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier)
     {
-        std::string lowercase = getLowercase(name);
+        const std::string& lowercase = getLowercase(name);
         if (!identifier)
         {
             std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase);
             if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd())
-                return (*it).second;
+                return it->second;
         }
         else
@@ -536,29 +536,29 @@
             std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase);
             if (it != identifier->getLowercaseConsoleCommandMapEnd())
-                return (*it).second;
+                return it->second;
         }
         return 0;
     }
 
-    std::string CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
+    const std::string& CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
     {
         CommandExecutor::createArgumentCompletionList(command, param);
 
-        std::string lowercase = getLowercase(name);
+        const std::string& lowercase = getLowercase(name);
         for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
         {
-            if ((*it).lowercaseComparison())
-            {
-                if ((*it).getComparable() == lowercase)
-                    return (*it).getString();
+            if (it->lowercaseComparison())
+            {
+                if (it->getComparable() == lowercase)
+                    return it->getString();
             }
             else
             {
-                if ((*it).getComparable() == name)
-                    return (*it).getString();
-            }
-        }
-
-        return "";
+                if (it->getComparable() == name)
+                    return it->getString();
+            }
+        }
+
+        return BLANKSTRING;
     }
 
@@ -589,9 +589,9 @@
         else if (list.size() == 1)
         {
-            return ((*(*list.begin()).first) + " ");
-        }
-        else
-        {
-            std::string output = "";
+            return ((*list.begin()->first) + ' ');
+        }
+        else
+        {
+            std::string output;
             for (unsigned int i = 0; true; i++)
             {
@@ -599,13 +599,13 @@
                 for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
                 {
-                    if ((*(*it).first).size() > i)
+                    if (it->first->size() > i)
                     {
                         if (it == list.begin())
                         {
-                            temp = (*(*it).first)[i];
+                            temp = (*it->first)[i];
                         }
                         else
                         {
-                            if (temp != (*(*it).first)[i])
+                            if (temp != (*it->first)[i])
                                 return output;
                         }
@@ -630,25 +630,30 @@
         else if (list.size() == 1)
         {
-            return ((*list.begin()).getComparable() + " ");
-        }
-        else
-        {
-            std::string output = "";
+            return (list.begin()->getComparable() + ' ');
+        }
+        else
+        {
+            std::string output;
             for (unsigned int i = 0; true; i++)
             {
+                char tempComparable = 0;
                 char temp = 0;
                 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
                 {
-                    std::string argument = (*it).getComparable();
+                    const std::string& argumentComparable = it->getComparable();
+                    const std::string& argument = it->getString();
                     if (argument.size() > i)
                     {
                         if (it == list.begin())
                         {
+                            tempComparable = argumentComparable[i];
                             temp = argument[i];
                         }
                         else
                         {
-                            if (temp != argument[i])
+                            if (tempComparable != argumentComparable[i])
                                 return output;
+                            else if (temp != argument[i])
+                                temp = tempComparable;
                         }
                     }
