mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 02:45:32 +00:00
Fixing performance-faster-string-find issues
This addresses the Clang Tidy check [performance-faster-string-find](https://clang.llvm.org/extra/clang-tidy/checks/performance-faster-string-find.html).
This commit is contained in:
parent
caf382c19f
commit
339d347aea
9 changed files with 14 additions and 14 deletions
|
@ -686,12 +686,12 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const boost::filesystem::p
|
|||
continue;
|
||||
}
|
||||
|
||||
int comment_pos = line.find(";");
|
||||
int comment_pos = line.find(';');
|
||||
if(comment_pos > 0) {
|
||||
line = line.substr(0,comment_pos);
|
||||
}
|
||||
|
||||
int pos = line.find("=");
|
||||
int pos = line.find('=');
|
||||
if(pos < 1) {
|
||||
continue;
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const boost::filesystem::p
|
|||
while (std::getline(file, line)) {
|
||||
|
||||
// we cant say comment by only looking at first char anymore
|
||||
int comment_pos = line.find("#");
|
||||
int comment_pos = line.find('#');
|
||||
if(comment_pos > 0) {
|
||||
line = line.substr(0,comment_pos);
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ MwIniImporter::multistrmap MwIniImporter::loadCfgFile(const boost::filesystem::p
|
|||
continue;
|
||||
}
|
||||
|
||||
int pos = line.find("=");
|
||||
int pos = line.find('=');
|
||||
if(pos < 1) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace bfs = boost::filesystem;
|
|||
///See if the file has the named extension
|
||||
bool hasExtension(std::string filename, std::string extensionToFind)
|
||||
{
|
||||
std::string extension = filename.substr(filename.find_last_of(".")+1);
|
||||
std::string extension = filename.substr(filename.find_last_of('.')+1);
|
||||
|
||||
//Convert strings to lower case for comparison
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
||||
|
|
|
@ -178,7 +178,7 @@ namespace CSMPrefs
|
|||
{
|
||||
const int MaxKeys = 4; // A limitation of QKeySequence
|
||||
|
||||
size_t end = data.find(";");
|
||||
size_t end = data.find(';');
|
||||
size_t size = std::min(end, data.size());
|
||||
|
||||
std::string value = data.substr(0, size);
|
||||
|
@ -191,7 +191,7 @@ namespace CSMPrefs
|
|||
|
||||
while (start < value.size())
|
||||
{
|
||||
end = data.find("+", start);
|
||||
end = data.find('+', start);
|
||||
end = std::min(end, value.size());
|
||||
|
||||
std::string name = value.substr(start, end - start);
|
||||
|
@ -243,7 +243,7 @@ namespace CSMPrefs
|
|||
|
||||
void ShortcutManager::convertFromString(const std::string& data, int& modifier) const
|
||||
{
|
||||
size_t start = data.find(";") + 1;
|
||||
size_t start = data.find(';') + 1;
|
||||
start = std::min(start, data.size());
|
||||
|
||||
std::string name = data.substr(start);
|
||||
|
|
|
@ -332,7 +332,7 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe
|
|||
|
||||
int textureColumn = landTable.findColumnIndex(CSMWorld::Columns::ColumnId_LandTexturesIndex);
|
||||
|
||||
std::size_t hashlocation = mBrushTexture.find("#");
|
||||
std::size_t hashlocation = mBrushTexture.find('#');
|
||||
std::string mBrushTextureInt = mBrushTexture.substr (hashlocation+1);
|
||||
int brushInt = stoi(mBrushTexture.substr (hashlocation+1))+1; // All indices are offset by +1
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ namespace MWGui
|
|||
std::map<std::string, std::string> userStrings = focus->getUserStrings();
|
||||
for (auto& userStringPair : userStrings)
|
||||
{
|
||||
size_t underscorePos = userStringPair.first.find("_");
|
||||
size_t underscorePos = userStringPair.first.find('_');
|
||||
if (underscorePos == std::string::npos)
|
||||
continue;
|
||||
std::string key = userStringPair.first.substr(0, underscorePos);
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace Debug
|
|||
if (str.length() == 0)
|
||||
return true;
|
||||
|
||||
return str.find("OFF") == std::string::npos && str.find("0") == std::string::npos && str.find("NO") == std::string::npos;
|
||||
return str.find("OFF") == std::string::npos && str.find('0') == std::string::npos && str.find("NO") == std::string::npos;
|
||||
}
|
||||
|
||||
DebugGroup::DebugGroup(const std::string & message, GLuint id)
|
||||
|
|
|
@ -12,7 +12,7 @@ void Fallback::validate(boost::any& v, std::vector<std::string> const& tokens, F
|
|||
for (const auto& token : tokens)
|
||||
{
|
||||
std::string temp = Files::EscapeHashString::processString(token);
|
||||
size_t sep = temp.find(",");
|
||||
size_t sep = temp.find(',');
|
||||
if (sep < 1 || sep == temp.length() - 1 || sep == std::string::npos)
|
||||
throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value);
|
||||
|
||||
|
|
|
@ -500,7 +500,7 @@ namespace Resource
|
|||
{
|
||||
std::string str(env);
|
||||
|
||||
if(str.find("OFF")!=std::string::npos || str.find("0")!= std::string::npos) options = 0;
|
||||
if(str.find("OFF")!=std::string::npos || str.find('0')!= std::string::npos) options = 0;
|
||||
|
||||
if(str.find("~FLATTEN_STATIC_TRANSFORMS")!=std::string::npos) options ^= Optimizer::FLATTEN_STATIC_TRANSFORMS;
|
||||
else if(str.find("FLATTEN_STATIC_TRANSFORMS")!=std::string::npos) options |= Optimizer::FLATTEN_STATIC_TRANSFORMS;
|
||||
|
|
|
@ -118,7 +118,7 @@ namespace Gui
|
|||
|
||||
void ImageButton::setImage(const std::string &image)
|
||||
{
|
||||
size_t extpos = image.find_last_of(".");
|
||||
size_t extpos = image.find_last_of('.');
|
||||
std::string imageNoExt = image.substr(0, extpos);
|
||||
|
||||
std::string ext = image.substr(extpos);
|
||||
|
|
Loading…
Reference in a new issue