Simplify token string access

"internal" check reported:
[lib/tokenize.cpp:6671]: (style) Call to 'Token::tokAt()' followed by 'Token::str()' can be simplified.
This commit is contained in:
Thomas Jarosch 2013-01-15 20:37:02 +01:00
parent 5c8b05ce94
commit f4227967ce
1 changed files with 1 additions and 1 deletions

View File

@ -6668,7 +6668,7 @@ void Tokenizer::simplifyCharAt()
// Replace "string"[0] with 's'
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (Token::Match(tok, "%str% [ %num% ]")) {
const MathLib::bigint index = MathLib::toLongNumber(tok->tokAt(2)->str());
const MathLib::bigint index = MathLib::toLongNumber(tok->strAt(2));
// Check within range
if (index >= 0 && index <= (MathLib::bigint)Token::getStrLength(tok)) {
tok->str(std::string("'" + Token::getCharAt(tok, (size_t)index) + "'"));