From f8371f65f09f017e4c71497be1d815ae27317930 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Fri, 31 Oct 2014 17:17:25 +0100 Subject: [PATCH] Refactorization: Avoid string copying. --- lib/tokenize.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 27e0b5a36..c258568d7 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5955,7 +5955,7 @@ void Tokenizer::simplifyVariableMultipleAssign() Token *stopAt = tok->tokAt(2); const Token *valueTok = tok->tokAt(4); - const std::string value(valueTok->str()); + const std::string& value(valueTok->str()); tok2 = tok2->next(); while (tok2 != stopAt) { @@ -6037,7 +6037,7 @@ void Tokenizer::simplifyIfNotNull() // Remove 'x = (x != 0)' if (Token::simpleMatch(tok, "= (")) { if (Token::Match(tok->tokAt(-2), "[;{}] %var%")) { - const std::string varname(tok->previous()->str()); + const std::string& varname(tok->previous()->str()); if (Token::simpleMatch(tok->tokAt(2), (varname + " != 0 ) ;").c_str()) || Token::simpleMatch(tok->tokAt(2), ("0 != " + varname + " ) ;").c_str())) { @@ -8037,7 +8037,7 @@ bool Tokenizer::isFunctionParameterPassedByValue(const Token *fpar) const // Is this a function call? if (ftok && Token::Match(ftok->tokAt(-2), "[;{}=] %var% (")) { - const std::string functionName(ftok->previous()->str()); + const std::string& functionName(ftok->previous()->str()); if (functionName == "return") return true;