1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 11:23:51 +00:00

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)
This commit is contained in:
cc9cii 2015-12-11 22:18:17 +11:00
parent 86945d1912
commit 47b5fa9dae

View file

@ -1,6 +1,5 @@
#include "refcollection.hpp"
#include <sstream>
#include <iostream>
#include <components/misc/stringops.hpp>
@ -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<int, int> 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