From 47b5fa9dae72c35546fd172c9e06929c6ec39042 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 11 Dec 2015 22:18:17 +1100 Subject: [PATCH] Convert some of ostringstream << operations to std::to_sting() calls. - At least with MSVC the latter is more efficient. - There are many more, but leave them until they show up during profiling (so far only loading was profiled, and mainly cell references) --- apps/opencs/model/world/refcollection.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/opencs/model/world/refcollection.cpp b/apps/opencs/model/world/refcollection.cpp index 26ec507db2..607e5690dd 100644 --- a/apps/opencs/model/world/refcollection.cpp +++ b/apps/opencs/model/world/refcollection.cpp @@ -1,6 +1,5 @@ #include "refcollection.hpp" -#include #include #include @@ -63,10 +62,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool // ignoring moved references sub-record; instead calculate cell from coordinates std::pair index = ref.getCellIndex(); - std::ostringstream stream; - stream << "#" << index.first << " " << index.second; - - ref.mCell = stream.str(); + ref.mCell = "#" + std::to_string(index.first) + " " + std::to_string(index.second); if (!base && // don't try to update base records mref.mRefNum.mIndex != 0) // MVRF tag found @@ -91,9 +87,8 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool std::cerr << "Position: #" << index.first << " " << index.second <<", Target #"<< mref.mTarget[0] << " " << mref.mTarget[1] << std::endl; - std::ostringstream stream2; - stream2 << "#" << mref.mTarget[0] << " " << mref.mTarget[1]; - ref.mCell = stream2.str(); // overwrite + // overwrite + ref.mCell = "#" + std::to_string(mref.mTarget[0]) + " " + std::to_string(mref.mTarget[1]); } } } @@ -187,9 +182,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool std::string CSMWorld::RefCollection::getNewId() { - std::ostringstream stream; - stream << "ref#" << mNextId++; - return stream.str(); + return "ref#" + std::to_string(mNextId++); } unsigned int CSMWorld::RefCollection::extractIdNum (const std::string& id) const