Token: introduce str(const std::string &) method.
Get rid of useless std::string.c_str() calls. No functional change.
This commit is contained in:
parent
bc32d04efa
commit
4286fdbabb
|
@ -44,7 +44,7 @@ Token::~Token()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::str(const char s[])
|
void Token::str(const std::string &s)
|
||||||
{
|
{
|
||||||
_str = s;
|
_str = s;
|
||||||
_isName = bool(_str[0] == '_' || std::isalpha(_str[0]));
|
_isName = bool(_str[0] == '_' || std::isalpha(_str[0]));
|
||||||
|
@ -57,6 +57,11 @@ void Token::str(const char s[])
|
||||||
_varId = 0;
|
_varId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Token::str(const char s[])
|
||||||
|
{
|
||||||
|
str(std::string(s));
|
||||||
|
}
|
||||||
|
|
||||||
void Token::concatStr(std::string const& b)
|
void Token::concatStr(std::string const& b)
|
||||||
{
|
{
|
||||||
_str.erase(_str.length() - 1);
|
_str.erase(_str.length() - 1);
|
||||||
|
|
|
@ -26,6 +26,8 @@ class Token
|
||||||
public:
|
public:
|
||||||
Token();
|
Token();
|
||||||
~Token();
|
~Token();
|
||||||
|
|
||||||
|
void str(const std::string &s);
|
||||||
void str(const char s[]);
|
void str(const char s[]);
|
||||||
|
|
||||||
void concatStr(std::string const& b);
|
void concatStr(std::string const& b);
|
||||||
|
|
|
@ -104,7 +104,7 @@ void Tokenizer::addtoken(const char str[], const unsigned int lineno, const unsi
|
||||||
{
|
{
|
||||||
_tokens = new Token;
|
_tokens = new Token;
|
||||||
_tokensBack = _tokens;
|
_tokensBack = _tokens;
|
||||||
_tokensBack->str(str2.str().c_str());
|
_tokensBack->str(str2.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
_tokensBack->linenr(lineno);
|
_tokensBack->linenr(lineno);
|
||||||
|
@ -1257,7 +1257,7 @@ void Tokenizer::simplifyTokenList()
|
||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << SizeOfType(tok->strAt(2));
|
str << SizeOfType(tok->strAt(2));
|
||||||
tok->str(str.str().c_str());
|
tok->str(str.str());
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
@ -1279,7 +1279,7 @@ void Tokenizer::simplifyTokenList()
|
||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << size;
|
str << size;
|
||||||
tok->str(str.str().c_str());
|
tok->str(str.str());
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
|
@ -1307,7 +1307,7 @@ void Tokenizer::simplifyTokenList()
|
||||||
{
|
{
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
ostr << sz;
|
ostr << sz;
|
||||||
tok->str(ostr.str().c_str());
|
tok->str(ostr.str());
|
||||||
while (tok->next()->str() != ")")
|
while (tok->next()->str() != ")")
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
|
@ -1356,7 +1356,7 @@ void Tokenizer::simplifyTokenList()
|
||||||
{
|
{
|
||||||
std::ostringstream str;
|
std::ostringstream str;
|
||||||
str << total_size;
|
str << total_size;
|
||||||
tok2->str(str.str().c_str());
|
tok2->str(str.str());
|
||||||
// Delete the other tokens..
|
// Delete the other tokens..
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
@ -2334,7 +2334,7 @@ bool Tokenizer::simplifyIfNot()
|
||||||
if (Token::Match(tok, "%var% == 0"))
|
if (Token::Match(tok, "%var% == 0"))
|
||||||
{
|
{
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
tok->next()->str(tok->str().c_str());
|
tok->next()->str(tok->str());
|
||||||
tok->str("!");
|
tok->str("!");
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue