mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 15:15:32 +00:00
Reduce the call to tolower() for each character when the string is already in lower case.
- only a minor performance gain according to the MSVC profiler
This commit is contained in:
parent
abe6904a94
commit
90b76801f6
2 changed files with 16 additions and 1 deletions
|
@ -106,10 +106,11 @@ int CSMWorld::InfoCollection::getInfoIndex (const std::string& id, const std::st
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// brute force loop
|
// brute force loop
|
||||||
|
std::string lowerId = Misc::StringUtils::lowerCase (id);
|
||||||
for (std::vector<std::pair<std::string, int> >::const_iterator it = iter->second.begin();
|
for (std::vector<std::pair<std::string, int> >::const_iterator it = iter->second.begin();
|
||||||
it != iter->second.end(); ++it)
|
it != iter->second.end(); ++it)
|
||||||
{
|
{
|
||||||
if (Misc::StringUtils::ciEqual(it->first, id))
|
if (Misc::StringUtils::cEqual(it->first, lowerId))
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,20 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool cEqual(const std::string &x, const std::string &y) {
|
||||||
|
if (x.size() != y.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::string::const_iterator xit = x.begin();
|
||||||
|
std::string::const_iterator yit = y.begin();
|
||||||
|
for (; xit != x.end(); ++xit, ++yit) {
|
||||||
|
if (*xit != *yit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int ciCompareLen(const std::string &x, const std::string &y, size_t len)
|
static int ciCompareLen(const std::string &x, const std::string &y, size_t len)
|
||||||
{
|
{
|
||||||
std::string::const_iterator xit = x.begin();
|
std::string::const_iterator xit = x.begin();
|
||||||
|
|
Loading…
Reference in a new issue