Adapt Token::strAt() to return a const reference like Token::str() does
Saves us a complete conversion from string.c_str() back to std::string.
This commit is contained in:
parent
527236b321
commit
a645235d5a
|
@ -233,10 +233,12 @@ Token *Token::linkAt(int index)
|
|||
return tok->link();
|
||||
}
|
||||
|
||||
std::string Token::strAt(int index) const
|
||||
const std::string &Token::strAt(int index) const
|
||||
{
|
||||
static const std::string empty_str;
|
||||
|
||||
const Token *tok = this->tokAt(index);
|
||||
return tok ? tok->_str.c_str() : "";
|
||||
return tok ? tok->_str : empty_str;
|
||||
}
|
||||
|
||||
static bool strisop(const char str[])
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
const Token *linkAt(int index) const;
|
||||
Token *linkAt(int index);
|
||||
|
||||
std::string strAt(int index) const;
|
||||
const std::string &strAt(int index) const;
|
||||
|
||||
/**
|
||||
* Match given token (or list of tokens) to a pattern list.
|
||||
|
|
Loading…
Reference in New Issue