Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10918


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

Use emplace_back instead of push_back if beneficial

Location:
code/branches/cpp11_v2/src
Files:
25 edited

Legend:

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

    r10817 r10918  
    145145        // Create directories to avoid problems when opening files in non existent folders.
    146146        std::vector<std::pair<bf::path, std::string>> directories;
    147         directories.push_back(std::make_pair(bf::path(configPath_), std::string("config")));
    148         directories.push_back(std::make_pair(bf::path(logPath_), std::string("log")));
     147        directories.emplace_back(bf::path(configPath_), std::string("config"));
     148        directories.emplace_back(bf::path(logPath_), std::string("log"));
    149149
    150150        for (std::vector<std::pair<bf::path, std::string>>::iterator it = directories.begin();
  • code/branches/cpp11_v2/src/libraries/core/Game.cc

    r10916 r10918  
    464464            while (pos < str.size() && str[pos] != ' ')
    465465                ++pos;
    466             stateStrings.push_back(std::make_pair(str.substr(startPos, pos - startPos), indentation));
     466            stateStrings.emplace_back(str.substr(startPos, pos - startPos), indentation);
    467467        }
    468468        if (stateStrings.empty())
    469469            ThrowException(GameState, "Emtpy GameState hierarchy provided, terminating.");
    470470        // Add element with large identation to detect the last with just an iterator
    471         stateStrings.push_back(std::make_pair(std::string(), -1));
     471        stateStrings.emplace_back(std::string(), -1);
    472472
    473473        // Parse elements recursively
  • code/branches/cpp11_v2/src/libraries/core/LuaState.cc

    r10916 r10918  
    259259            {
    260260                //Add the new line to the trace map
    261                 lineTrace_->push_back(std::vector<std::pair<std::string, size_t>>());
     261                lineTrace_->emplace_back();
    262262                //Add the source of the line at the end
    263                 lineTrace_->rbegin()->push_back(std::make_pair(filename, line + i));
     263                lineTrace_->rbegin()->emplace_back(filename, line + i);
    264264            }
    265265        }
  • code/branches/cpp11_v2/src/libraries/core/LuaState.h

    r10771 r10918  
    9595
    9696        void setTraceMap(std::shared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> map)
    97             { map->push_back(std::vector<std::pair<std::string, size_t>>()); lineTrace_ = map; }
     97            { map->emplace_back(); lineTrace_ = map; }
    9898
    9999        void setIncludeParser(std::string (*function)(const std::string&)) { includeParseFunction_ = function; }
  • code/branches/cpp11_v2/src/libraries/core/class/Identifier.h

    r10916 r10918  
    363363
    364364            // Add pointer of type T to the map in the Identifiable instance that enables "dynamic_casts"
    365             object->objectPointers_.push_back(std::make_pair(this->getClassID(), static_cast<void*>(object)));
     365            object->objectPointers_.emplace_back(this->getClassID(), static_cast<void*>(object));
    366366            return false;
    367367        }
  • 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    }
  • code/branches/cpp11_v2/src/libraries/core/config/ConfigValueContainer.cc

    r10768 r10918  
    191191                for (unsigned int i = this->valueVector_.size(); i <= index; i++)
    192192                {
    193                     this->valueVector_.push_back(MultiType());
     193                    this->valueVector_.emplace_back();
    194194                }
    195195            }
  • code/branches/cpp11_v2/src/libraries/core/config/ConfigValueContainer.h

    r10916 r10918  
    131131                this->value_ = V();
    132132                for (const D& defvalueElement : defvalue)
    133                     this->valueVector_.push_back(MultiType(defvalueElement));
     133                    this->valueVector_.emplace_back(defvalueElement);
    134134
    135135                this->initVector();
  • code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.cc

    r10916 r10918  
    188188    {
    189189        while (joyStickAxes_.size() < joySticks_.size())
    190             joyStickAxes_.push_back(std::shared_ptr<JoyStickAxisVector>(std::make_shared<JoyStickAxisVector>()));
     190            joyStickAxes_.push_back(std::make_shared<JoyStickAxisVector>());
    191191        while (joyStickButtons_.size() < joySticks_.size())
    192             joyStickButtons_.push_back(std::shared_ptr<JoyStickButtonVector>(std::make_shared<JoyStickButtonVector>()));
     192            joyStickButtons_.push_back(std::make_shared<JoyStickButtonVector>());
    193193        // For the case the new size is smaller
    194194        this->joyStickAxes_.resize(joySticks_.size());
  • code/branches/cpp11_v2/src/libraries/network/FunctionCall.cc

    r10916 r10918  
    119119  for( unsigned int i=0; i<this->nrOfArguments_; ++i )
    120120  {
    121     this->arguments_.push_back(MultiType());
     121    this->arguments_.emplace_back();
    122122    this->arguments_.back().importData(mem);
    123123  }
  • code/branches/cpp11_v2/src/libraries/network/FunctionCallManager.cc

    r10769 r10918  
    6565void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID)
    6666{
    67   FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( std::make_pair(fctCall, std::make_pair(minGamestateID, peerID)));
     67  FunctionCallManager::sIncomingFunctionCallBuffer_.emplace_back(fctCall, std::make_pair(minGamestateID, peerID));
    6868}
    6969
  • code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.cc

    r10768 r10918  
    133133    tempsize = it->getData(mem, this->sizes_, id, mode);
    134134    if ( tempsize != 0 )
    135       dataVector_.push_back( obj(it->getObjectID(), it->getContextID(), tempsize, mem-data_) );
     135      dataVector_.emplace_back(it->getObjectID(), it->getContextID(), tempsize, mem-data_);
    136136
    137137#ifndef NDEBUG
  • code/branches/cpp11_v2/src/libraries/tools/DebugDrawer.cc

    r10916 r10918  
    433433    int DebugDrawer::addLineVertex(const Ogre::Vector3& vertex, const Ogre::ColourValue& colour)
    434434    {
    435         lineVertices.push_back(VertexPair(vertex, colour));
     435        lineVertices.emplace_back(vertex, colour);
    436436        return linesIndex++;
    437437    }
     
    445445    int DebugDrawer::addTriangleVertex(const Ogre::Vector3& vertex, const Ogre::ColourValue& colour)
    446446    {
    447         triangleVertices.push_back(VertexPair(vertex, colour));
     447        triangleVertices.emplace_back(vertex, colour);
    448448        return trianglesIndex++;
    449449    }
  • code/branches/cpp11_v2/src/libraries/tools/DynamicLines.cc

    r5781 r10918  
    6969    void DynamicLines::addPoint(Real x, Real y, Real z)
    7070    {
    71         mPoints.push_back(Vector3(x,y,z));
     71        mPoints.emplace_back(x,y,z);
    7272        mDirty = true;
    7373    }
  • code/branches/cpp11_v2/src/libraries/tools/IcoSphere.cc

    r10916 r10918  
    126126                removeLineIndices(f.v3, f.v1);
    127127
    128                 faces2.push_back(TriangleIndices(f.v1, a, c));
    129                 faces2.push_back(TriangleIndices(f.v2, b, a));
    130                 faces2.push_back(TriangleIndices(f.v3, c, b));
    131                 faces2.push_back(TriangleIndices(a, b, c));
     128                faces2.emplace_back(f.v1, a, c);
     129                faces2.emplace_back(f.v2, b, a);
     130                faces2.emplace_back(f.v3, c, b);
     131                faces2.emplace_back(a, b, c);
    132132
    133133                addTriangleLines(f.v1, a, c);
     
    142142    void IcoSphere::addLineIndices(int index0, int index1)
    143143    {
    144         lineIndices.push_back(LineIndices(index0, index1));
     144        lineIndices.emplace_back(index0, index1);
    145145    }
    146146
     
    163163    {
    164164        Ogre::Real length = vertex.length();
    165         vertices.push_back(Ogre::Vector3(vertex.x / length, vertex.y / length, vertex.z / length));
     165        vertices.emplace_back(vertex.x / length, vertex.y / length, vertex.z / length);
    166166        return index++;
    167167    }
     
    188188    void IcoSphere::addFace(int index0, int index1, int index2)
    189189    {
    190         faces.push_back(TriangleIndices(index0, index1, index2));
     190        faces.emplace_back(index0, index1, index2);
    191191    }
    192192
     
    217217
    218218        for (const Ogre::Vector3& vertex : vertices)
    219             target->push_back(VertexPair(transform * vertex, colour));
     219            target->emplace_back(transform * vertex, colour);
    220220
    221221        return vertices.size();
  • code/branches/cpp11_v2/src/libraries/util/SubString.cc

    r9550 r10918  
    112112        for (size_t i = 0; i < argc; ++i)
    113113        {
    114             this->tokens_.push_back(std::string(argv[i]));
     114            this->tokens_.emplace_back(argv[i]);
    115115            this->bTokenInSafemode_.push_back(false);
    116116        }
  • code/branches/cpp11_v2/src/libraries/util/output/BaseWriter.cc

    r10916 r10918  
    4747        this->configurableMaxLevel_ = level::none;
    4848        this->configurableAdditionalContextsMaxLevel_ = level::verbose;
    49         this->configurableAdditionalContexts_.push_back("example");
     49        this->configurableAdditionalContexts_.emplace_back("example");
    5050
    5151        this->changedConfigurableLevel();
  • code/branches/cpp11_v2/src/libraries/util/output/MemoryWriter.cc

    r10916 r10918  
    5757    void MemoryWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
    5858    {
    59         this->messages_.push_back(Message(level, context, lines));
     59        this->messages_.emplace_back(level, context, lines);
    6060    }
    6161
  • code/branches/cpp11_v2/src/modules/designtools/SkyboxGenerator.cc

    r10765 r10918  
    8282        this->faceCounter_ = 0;
    8383       
    84         this->names_.push_back("fr");
    85         this->names_.push_back("lf");
    86         this->names_.push_back("bk");
    87         this->names_.push_back("rt");
    88         this->names_.push_back("up");
    89         this->names_.push_back("dn");
    90        
    91         this->rotations_.push_back(std::pair<int, int>(90, 0));
    92         this->rotations_.push_back(std::pair<int, int>(90, 0));
    93         this->rotations_.push_back(std::pair<int, int>(90, 0));
    94         this->rotations_.push_back(std::pair<int, int>(90, 90));
    95         this->rotations_.push_back(std::pair<int, int>(0, 180));
    96         this->rotations_.push_back(std::pair<int, int>(0, 90));
     84        this->names_.emplace_back("fr");
     85        this->names_.emplace_back("lf");
     86        this->names_.emplace_back("bk");
     87        this->names_.emplace_back("rt");
     88        this->names_.emplace_back("up");
     89        this->names_.emplace_back("dn");
     90       
     91        this->rotations_.emplace_back(90, 0);
     92        this->rotations_.emplace_back(90, 0);
     93        this->rotations_.emplace_back(90, 0);
     94        this->rotations_.emplace_back(90, 90);
     95        this->rotations_.emplace_back(0, 180);
     96        this->rotations_.emplace_back(0, 90);
    9797    }
    9898
  • code/branches/cpp11_v2/src/modules/objects/triggers/MultiTrigger.cc

    r10916 r10918  
    265265                else
    266266                {
    267                     this->stateQueue_.push_back(std::pair<float, MultiTriggerState*>(timeRemaining-dt, state));
     267                    this->stateQueue_.emplace_back(timeRemaining-dt, state);
    268268                    this->stateQueue_.pop_front();
    269269                }
     
    489489
    490490        // Add it ot the state queue with the delay specified for the MultiTrigger.
    491         this->stateQueue_.push_back(std::pair<float, MultiTriggerState*>(this->getDelay(), state));
     491        this->stateQueue_.emplace_back(this->getDelay(), state);
    492492
    493493        return true;
  • code/branches/cpp11_v2/src/modules/pong/PongAI.cc

    r10916 r10918  
    362362            // Add a new Timer
    363363            Timer* timer = new Timer(delay, false, createExecutor(createFunctor(&PongAI::delayedMove, this)));
    364             this->reactionTimers_.push_back(std::pair<Timer*, char>(timer, direction));
     364            this->reactionTimers_.emplace_back(timer, direction);
    365365        }
    366366        else
  • code/branches/cpp11_v2/src/orxonox/sound/SoundManager.cc

    r10916 r10918  
    576576            ALuint source = this->availableSoundSources_.back();
    577577            this->availableSoundSources_.pop_back();
    578             this->usedSoundSources_.push_back(std::make_pair(source, object));
     578            this->usedSoundSources_.emplace_back(source, object);
    579579            return source;
    580580        }
     
    588588                if (alIsSource(source) && !alGetError())
    589589                {
    590                     this->usedSoundSources_.push_back(std::make_pair(source, object));
     590                    this->usedSoundSources_.emplace_back(source, object);
    591591                    return source;
    592592                }
  • code/branches/cpp11_v2/src/orxonox/sound/WorldAmbientSound.cc

    r10624 r10918  
    4949        this->ambientSound_ = new AmbientSound();
    5050        this->registerVariables();
    51         soundList_.push_back("Earth.ogg");
    52         soundList_.push_back("Jupiter.ogg");
    53         soundList_.push_back("Mars.ogg");
    54         soundList_.push_back("allgorythm-lift_up.ogg");
    55         soundList_.push_back("allgorythm-resonance_blaster.ogg");
    56         soundList_.push_back("AlphaCentauri.ogg");
    57         soundList_.push_back("Asteroid_rocks.ogg");
    58         soundList_.push_back("Ganymede.ogg");
    59         soundList_.push_back("luke_grey_-_hypermode.ogg");
     51        soundList_.emplace_back("Earth.ogg");
     52        soundList_.emplace_back("Jupiter.ogg");
     53        soundList_.emplace_back("Mars.ogg");
     54        soundList_.emplace_back("allgorythm-lift_up.ogg");
     55        soundList_.emplace_back("allgorythm-resonance_blaster.ogg");
     56        soundList_.emplace_back("AlphaCentauri.ogg");
     57        soundList_.emplace_back("Asteroid_rocks.ogg");
     58        soundList_.emplace_back("Ganymede.ogg");
     59        soundList_.emplace_back("luke_grey_-_hypermode.ogg");
    6060
    6161    }
Note: See TracChangeset for help on using the changeset viewer.