mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-17 10:21:11 +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
@ -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…
x
Reference in New Issue
Block a user