Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10772 for code


Ignore:
Timestamp:
Nov 7, 2015, 5:38:21 PM (9 years ago)
Author:
landauf
Message:

use std::make_shared for better performance with shared_ptr

Location:
code/branches/cpp11_v2/src/libraries/core
Files:
5 edited

Legend:

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

    r10771 r10772  
    123123
    124124        // The empty root state is ALWAYS loaded!
    125         this->rootStateNode_ = std::shared_ptr<GameStateTreeNode>(new GameStateTreeNode());
     125        this->rootStateNode_ = std::shared_ptr<GameStateTreeNode>(std::make_shared<GameStateTreeNode>());
    126126        this->rootStateNode_->name_ = "emptyRootGameState";
    127127        this->loadedTopStateNode_ = this->rootStateNode_;
     
    490490            if (tokens[i] == this->rootStateNode_->name_)
    491491                ThrowException(GameState, "You shouldn't use 'emptyRootGameState' in the hierarchy...");
    492             std::shared_ptr<GameStateTreeNode> node(new GameStateTreeNode());
     492            std::shared_ptr<GameStateTreeNode> node(std::make_shared<GameStateTreeNode>());
    493493            node->name_ = tokens[i];
    494494            node->parent_ = currentNode;
  • code/branches/cpp11_v2/src/libraries/core/Game.h

    r10771 r10772  
    136136        public:
    137137            std::shared_ptr<GameState> fabricateInternal(const GameStateInfo& info)
    138                 { return std::shared_ptr<GameState>(new T(info)); }
     138                { return std::shared_ptr<GameState>(std::make_shared<T>(info)); }
    139139        };
    140140
  • code/branches/cpp11_v2/src/libraries/core/Loader.cc

    r10771 r10772  
    7373        std::string xmlInput;
    7474
    75         std::shared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> lineTrace(new std::vector<std::vector<std::pair<std::string, size_t>>>());
     75        std::shared_ptr<std::vector<std::vector<std::pair<std::string, size_t>>>> lineTrace(std::make_shared<std::vector<std::vector<std::pair<std::string, size_t>>>>());
    7676        lineTrace->reserve(1000); //arbitrary number
    7777
  • code/branches/cpp11_v2/src/libraries/core/Resource.cc

    r10771 r10772  
    9595            if (it->filename == name)
    9696            {
    97                 std::shared_ptr<ResourceInfo> ptr(new ResourceInfo());
     97                std::shared_ptr<ResourceInfo> ptr(std::make_shared<ResourceInfo>());
    9898                ptr->filename = name;
    9999                ptr->path = it->path;
  • code/branches/cpp11_v2/src/libraries/core/input/KeyBinder.cc

    r10771 r10772  
    188188    {
    189189        while (joyStickAxes_.size() < joySticks_.size())
    190             joyStickAxes_.push_back(std::shared_ptr<JoyStickAxisVector>(new JoyStickAxisVector()));
     190            joyStickAxes_.push_back(std::shared_ptr<JoyStickAxisVector>(std::make_shared<JoyStickAxisVector>()));
    191191        while (joyStickButtons_.size() < joySticks_.size())
    192             joyStickButtons_.push_back(std::shared_ptr<JoyStickButtonVector>(new JoyStickButtonVector()));
     192            joyStickButtons_.push_back(std::shared_ptr<JoyStickButtonVector>(std::make_shared<JoyStickButtonVector>()));
    193193        // For the case the new size is smaller
    194194        this->joyStickAxes_.resize(joySticks_.size());
Note: See TracChangeset for help on using the changeset viewer.