From f4ce49d88372d520e742c58045cbcf3110c7a918 Mon Sep 17 00:00:00 2001 From: uburuntu Date: Fri, 2 Jun 2017 22:38:00 +0400 Subject: [PATCH] ENH: perfomance: using clear() and empty() more faster for stl containers --- lib/checkbufferoverrun.cpp | 2 +- lib/checkstl.cpp | 2 +- lib/checkunusedfunctions.cpp | 2 +- lib/library.cpp | 2 +- lib/path.cpp | 2 +- lib/tokenize.cpp | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 596cd946f..59401ab55 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1645,7 +1645,7 @@ MathLib::biguint CheckBufferOverrun::countSprintfLength(const std::string &input input_string_size += tempDigits; parameterLength = 0; - digits_string = ""; + digits_string.clear(); i_d_x_f_found = false; percentCharFound = false; handleNextParameter = false; diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 8aa8d46d3..f8818cf69 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -610,7 +610,7 @@ void CheckStl::pushback() } else { vectorid = 0; } - invalidIterator = ""; + invalidIterator.clear(); } // push_back on vector.. diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 738136ccc..50b2d284f 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -176,7 +176,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi if (funcToken->str()==",") { if (++index == argIndex) break; - value = ""; + value.clear(); } else value += funcToken->str(); funcToken = funcToken->next(); diff --git a/lib/library.cpp b/lib/library.cpp index 6d78eebc6..a24b7d77a 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -72,7 +72,7 @@ Library::Error Library::load(const char exename[], const char path[]) if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) { // failed to open file.. is there no extension? std::string fullfilename(path); - if (Path::getFilenameExtension(fullfilename) == "") { + if (Path::getFilenameExtension(fullfilename).empty()) { fullfilename += ".cfg"; error = doc.LoadFile(fullfilename.c_str()); if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND) diff --git a/lib/path.cpp b/lib/path.cpp index ec31cad39..7ccb07337 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -84,7 +84,7 @@ std::string Path::simplifyPath(std::string originalPath) if (originalPath[i] == '/' || originalPath[i] == '\\') { if (subPath.length() > 0) { pathParts.push_back(subPath); - subPath = ""; + subPath.clear(); } pathParts.push_back(std::string(1 , originalPath[i])); diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 9c372c9eb..aa4a4a4a9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4782,7 +4782,7 @@ bool Tokenizer::simplifyConditions() // It is inconclusive whether two unequal float representations are numerically equal if (!eq && MathLib::isFloat(op1)) - cmp = ""; + cmp.clear(); } if (cmp == "==") @@ -4801,7 +4801,7 @@ bool Tokenizer::simplifyConditions() else if (cmp == "<") result = (op1 < op2); else - cmp = ""; + cmp.clear(); } } else { // Compare boolean @@ -4821,7 +4821,7 @@ bool Tokenizer::simplifyConditions() else if (cmp == "<") result = (op1 < op2); else - cmp = ""; + cmp.clear(); } if (! cmp.empty()) {