Skip to content

Commit f4ce49d

Browse files
committed
ENH: perfomance: using clear() and empty() more faster for stl containers
1 parent dc83f67 commit f4ce49d

6 files changed

Lines changed: 8 additions & 8 deletions

File tree

lib/checkbufferoverrun.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ MathLib::biguint CheckBufferOverrun::countSprintfLength(const std::string &input
16451645
input_string_size += tempDigits;
16461646

16471647
parameterLength = 0;
1648-
digits_string = "";
1648+
digits_string.clear();
16491649
i_d_x_f_found = false;
16501650
percentCharFound = false;
16511651
handleNextParameter = false;

lib/checkstl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ void CheckStl::pushback()
610610
} else {
611611
vectorid = 0;
612612
}
613-
invalidIterator = "";
613+
invalidIterator.clear();
614614
}
615615

616616
// push_back on vector..

lib/checkunusedfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
176176
if (funcToken->str()==",") {
177177
if (++index == argIndex)
178178
break;
179-
value = "";
179+
value.clear();
180180
} else
181181
value += funcToken->str();
182182
funcToken = funcToken->next();

lib/library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Library::Error Library::load(const char exename[], const char path[])
7272
if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) {
7373
// failed to open file.. is there no extension?
7474
std::string fullfilename(path);
75-
if (Path::getFilenameExtension(fullfilename) == "") {
75+
if (Path::getFilenameExtension(fullfilename).empty()) {
7676
fullfilename += ".cfg";
7777
error = doc.LoadFile(fullfilename.c_str());
7878
if (error != tinyxml2::XML_ERROR_FILE_NOT_FOUND)

lib/path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ std::string Path::simplifyPath(std::string originalPath)
8484
if (originalPath[i] == '/' || originalPath[i] == '\\') {
8585
if (subPath.length() > 0) {
8686
pathParts.push_back(subPath);
87-
subPath = "";
87+
subPath.clear();
8888
}
8989

9090
pathParts.push_back(std::string(1 , originalPath[i]));

lib/tokenize.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4782,7 +4782,7 @@ bool Tokenizer::simplifyConditions()
47824782

47834783
// It is inconclusive whether two unequal float representations are numerically equal
47844784
if (!eq && MathLib::isFloat(op1))
4785-
cmp = "";
4785+
cmp.clear();
47864786
}
47874787

47884788
if (cmp == "==")
@@ -4801,7 +4801,7 @@ bool Tokenizer::simplifyConditions()
48014801
else if (cmp == "<")
48024802
result = (op1 < op2);
48034803
else
4804-
cmp = "";
4804+
cmp.clear();
48054805
}
48064806
} else {
48074807
// Compare boolean
@@ -4821,7 +4821,7 @@ bool Tokenizer::simplifyConditions()
48214821
else if (cmp == "<")
48224822
result = (op1 < op2);
48234823
else
4824-
cmp = "";
4824+
cmp.clear();
48254825
}
48264826

48274827
if (! cmp.empty()) {

0 commit comments

Comments
 (0)