1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-20 19:39:41 +00:00

Use a char instead of a string in find() where possible

This was done via PVS Studio ( https://pvs-studio.com ),
and should provide a super-duper-marginal performance boost \o/
This commit is contained in:
jvoisin 2021-04-25 19:57:09 +02:00
parent 8edef1692f
commit 4c96644f8d
3 changed files with 5 additions and 4 deletions

View file

@ -273,7 +273,7 @@ namespace MWGui
std::string widgetName = userStringPair.first.substr(underscorePos+1, userStringPair.first.size()-(underscorePos+1));
type = "Property";
size_t caretPos = key.find("^");
size_t caretPos = key.find('^');
if (caretPos != std::string::npos)
{
type = key.substr(0, caretPos);

View file

@ -1017,8 +1017,9 @@ namespace MWGui
if(tag.compare(0, MyGuiPrefixLength, MyGuiPrefix) == 0)
{
tag = tag.substr(MyGuiPrefixLength, tag.length());
std::string settingSection = tag.substr(0, tag.find(","));
std::string settingTag = tag.substr(tag.find(",")+1, tag.length());
size_t comma_pos = tag.find(',');
std::string settingSection = tag.substr(0, comma_pos);
std::string settingTag = tag.substr(comma_pos+1, tag.length());
_result = Settings::Manager::getString(settingTag, settingSection);
}

View file

@ -966,7 +966,7 @@ void CharacterController::handleTextKey(const std::string &groupname, SceneUtil:
// The event can optionally contain volume and pitch modifiers
float volume=1.f, pitch=1.f;
if (soundgen.find(" ") != std::string::npos)
if (soundgen.find(' ') != std::string::npos)
{
std::vector<std::string> tokens;
split(soundgen, ' ', tokens);