Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2015, 7:10:56 PM (9 years ago)
Author:
muemart
Message:

Use emplace_back instead of push_back if beneficial

Location:
code/branches/cpp11_v2/src/libraries/core/command
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/core/command/ArgumentCompletionFunctions.cc

    r10916 r10918  
    102102                for (const auto& mapEntry : commands)
    103103                    if (groupIsVisible(mapEntry.second, bOnlyShowHidden) && mapEntry.first != "" && (fragmentLC == "" || getLowercase(mapEntry.first).find(fragmentLC) == 0))
    104                         groupList.push_back(ArgumentCompletionListElement(mapEntry.first, getLowercase(mapEntry.first)));
     104                        groupList.emplace_back(mapEntry.first, getLowercase(mapEntry.first));
    105105
    106106                // now add all shortcuts (in group "")
     
    110110                    // add a line-break if the list isn't empty
    111111                    if (!groupList.empty())
    112                         groupList.push_back(ArgumentCompletionListElement("", "", "\n"));
     112                        groupList.emplace_back("", "", "\n");
    113113
    114114                    // add the shortcuts
    115115                    for (const auto& mapEntry : it_group->second)
    116116                        if (mapEntry.second->isActive() && mapEntry.second->hasAccess() && (!mapEntry.second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(mapEntry.first).find(fragmentLC) == 0))
    117                             groupList.push_back(ArgumentCompletionListElement(mapEntry.first, getLowercase(mapEntry.first)));
     117                            groupList.emplace_back(mapEntry.first, getLowercase(mapEntry.first));
    118118                }
    119119
     
    148148                    for (const auto& mapEntry : it_group->second)
    149149                        if (mapEntry.second->isActive() && mapEntry.second->hasAccess() && (!mapEntry.second->isHidden())^bOnlyShowHidden)
    150                             commandList.push_back(ArgumentCompletionListElement(mapEntry.first, getLowercase(mapEntry.first)));
     150                            commandList.emplace_back(mapEntry.first, getLowercase(mapEntry.first));
    151151                }
    152152
     
    188188            {
    189189                ArgumentCompletionList list;
    190                 list.push_back(ArgumentCompletionListElement("", "", hint));
     190                list.emplace_back("", "", hint);
    191191                return list;
    192192            }
     
    261261                {
    262262                    if (boost::filesystem::is_directory(*file))
    263                         dirlist.push_back(ArgumentCompletionListElement(file->BF_DICTIONARY_ENTRY_NAME() + '/', getLowercase(file->BF_DICTIONARY_ENTRY_NAME()) + '/', file->BF_LEAF() + '/'));
     263                        dirlist.emplace_back(file->BF_DICTIONARY_ENTRY_NAME() + '/', getLowercase(file->BF_DICTIONARY_ENTRY_NAME()) + '/', file->BF_LEAF() + '/');
    264264                    else
    265                         filelist.push_back(ArgumentCompletionListElement(file->BF_DICTIONARY_ENTRY_NAME(), getLowercase(file->BF_DICTIONARY_ENTRY_NAME()), file->BF_LEAF()));
     265                        filelist.emplace_back(file->BF_DICTIONARY_ENTRY_NAME(), getLowercase(file->BF_DICTIONARY_ENTRY_NAME()), file->BF_LEAF());
    266266                    ++file;
    267267                }
     
    282282            const std::set<std::string>& names = SettingsConfigFile::getInstance().getSectionNames();
    283283            for (const std::string& name : names)
    284                 sectionList.push_back(ArgumentCompletionListElement(name, getLowercase(name)));
     284                sectionList.emplace_back(name, getLowercase(name));
    285285
    286286            return sectionList;
     
    298298            SettingsConfigFile::ContainerMap::const_iterator upper = settings.getContainerUpperBound(sectionLC);
    299299            for (SettingsConfigFile::ContainerMap::const_iterator it = settings.getContainerLowerBound(sectionLC); it != upper; ++it)
    300                 entryList.push_back(ArgumentCompletionListElement(it->second.second->getName(), it->second.first));
     300                entryList.emplace_back(it->second.second->getName(), it->second.first);
    301301
    302302            return entryList;
     
    319319                {
    320320                    const std::string& valuestring = it->second.second->toString();
    321                     oldValue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
     321                    oldValue.emplace_back(valuestring, getLowercase(valuestring), "Old value: " + valuestring);
    322322                }
    323323            }
     
    335335
    336336            for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)
    337                 threads.push_back(ArgumentCompletionListElement(multi_cast<std::string>(*it)));
     337                threads.emplace_back(multi_cast<std::string>(*it));
    338338
    339339            return threads;
  • code/branches/cpp11_v2/src/libraries/core/command/ArgumentCompletionFunctions.h

    r7401 r10918  
    8686        {
    8787            for (int month = 1; month <= 12; ++month)
    88                 list.push_back(ArgumentCompletionListElement(multi_cast<std::string>(month)));
     88                list.emplace_back(multi_cast<std::string>(month));
    8989        }
    9090        else
    9191        {
    92             list.push_back(ArgumentCompletionListElement("January",   "january"));
    93             list.push_back(ArgumentCompletionListElement("February",  "february"));
    94             list.push_back(ArgumentCompletionListElement("March",     "march"));
    95             list.push_back(ArgumentCompletionListElement("April",     "april"));
    96             list.push_back(ArgumentCompletionListElement("May",       "may"));
    97             list.push_back(ArgumentCompletionListElement("June",      "june"));
    98             list.push_back(ArgumentCompletionListElement("July",      "july"));
    99             list.push_back(ArgumentCompletionListElement("August",    "august"));
    100             list.push_back(ArgumentCompletionListElement("September", "september"));
    101             list.push_back(ArgumentCompletionListElement("October",   "october"));
    102             list.push_back(ArgumentCompletionListElement("November",  "november"));
    103             list.push_back(ArgumentCompletionListElement("December",  "december"));
     92            list.emplace_back("January",   "january");
     93            list.emplace_back("February",  "february");
     94            list.emplace_back("March",     "march");
     95            list.emplace_back("April",     "april");
     96            list.emplace_back("May",       "may");
     97            list.emplace_back("June",      "june");
     98            list.emplace_back("July",      "july");
     99            list.emplace_back("August",    "august");
     100            list.emplace_back("September", "september");
     101            list.emplace_back("October",   "october");
     102            list.emplace_back("November",  "november");
     103            list.emplace_back("December",  "december");
    104104        }
    105105
  • code/branches/cpp11_v2/src/libraries/core/command/ConsoleCommand.cc

    r10916 r10918  
    8484            this->executor_ = executor;
    8585
    86         this->names_.push_back(CommandName(group, name));
     86        this->names_.emplace_back(group, name);
    8787    }
    8888
     
    9999    ConsoleCommand& ConsoleCommand::addShortcut()
    100100    {
    101         this->names_.push_back(CommandName("", this->baseName_));
     101        this->names_.emplace_back("", this->baseName_);
    102102        return *this;
    103103    }
     
    108108    ConsoleCommand& ConsoleCommand::addShortcut(const std::string&  name)
    109109    {
    110         this->names_.push_back(CommandName("", name));
     110        this->names_.emplace_back("", name);
    111111        return *this;
    112112    }
     
    117117    ConsoleCommand& ConsoleCommand::addGroup(const std::string& group)
    118118    {
    119         this->names_.push_back(CommandName(group, this->baseName_));
     119        this->names_.emplace_back(group, this->baseName_);
    120120        return *this;
    121121    }
     
    126126    ConsoleCommand& ConsoleCommand::addGroup(const std::string& group, const std::string&  name)
    127127    {
    128         this->names_.push_back(CommandName(group, name));
     128        this->names_.emplace_back(group, name);
    129129        return *this;
    130130    }
Note: See TracChangeset for help on using the changeset viewer.