Avoid deep copying std::string

This commit is contained in:
Dmitry-Me 2015-08-07 17:16:41 +03:00
parent 4c843eb171
commit d81776b8c8
1 changed files with 4 additions and 5 deletions

View File

@ -526,7 +526,6 @@ void CheckIO::checkWrongPrintfScanfArguments()
const Token* argListTok = 0; // Points to first va_list argument
const Token* formatStringTok = 0; // Points to format string token
std::string formatString;
bool scan = false;
bool scanf_s = false;
@ -589,18 +588,18 @@ void CheckIO::checkWrongPrintfScanfArguments()
continue;
}
if (formatStringTok)
formatString = formatStringTok->str();
else
if (!formatStringTok)
continue;
const std::string& formatString = formatStringTok->str();
// Count format string parameters..
unsigned int numFormat = 0;
unsigned int numSecure = 0;
bool percent = false;
const Token* argListTok2 = argListTok;
std::set<unsigned int> parameterPositionsUsed;
for (std::string::iterator i = formatString.begin(); i != formatString.end(); ++i) {
for (std::string::const_iterator i = formatString.begin(); i != formatString.end(); ++i) {
if (*i == '%') {
percent = !percent;
} else if (percent && *i == '[') {