Merge pull request #718 from Dmitry-Me/cacheAndReuse3
Cache and reuse value
This commit is contained in:
commit
eead6862cc
|
@ -1734,9 +1734,10 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
for (std::size_t i = 0; i < _symbolDatabase->getVariableListSize(); i++) {
|
for (std::size_t i = 0; i < _symbolDatabase->getVariableListSize(); i++) {
|
||||||
const Variable* var = _symbolDatabase->getVariableFromVarId(i);
|
const Variable* var = _symbolDatabase->getVariableFromVarId(i);
|
||||||
if (var && var->isRValueReference()) {
|
if (var && var->isRValueReference()) {
|
||||||
const_cast<Token*>(var->typeEndToken())->str("&");
|
Token* endTok = const_cast<Token*>(var->typeEndToken());
|
||||||
const_cast<Token*>(var->typeEndToken())->insertToken("&");
|
endTok->str("&");
|
||||||
const_cast<Token*>(var->typeEndToken()->next())->scope(var->typeEndToken()->scope());
|
endTok->insertToken("&");
|
||||||
|
endTok->next()->scope(endTok->scope());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2100,10 +2101,11 @@ void Tokenizer::simplifyArrayAccessSyntax()
|
||||||
// 0[a] -> a[0]
|
// 0[a] -> a[0]
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (tok->isNumber() && Token::Match(tok, "%num% [ %name% ]")) {
|
if (tok->isNumber() && Token::Match(tok, "%num% [ %name% ]")) {
|
||||||
std::string temp = tok->str();
|
const std::string number(tok->str());
|
||||||
tok->str(tok->strAt(2));
|
Token* indexTok = tok->tokAt(2);
|
||||||
tok->varId(tok->tokAt(2)->varId());
|
tok->str(indexTok->str());
|
||||||
tok->tokAt(2)->str(temp);
|
tok->varId(indexTok->varId());
|
||||||
|
indexTok->str(number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue