Token: introduce str(const std::string &) method.

Get rid of useless std::string.c_str() calls.

No functional change.
This commit is contained in:
Slava Semushin 2009-06-14 13:55:23 +07:00
parent bc32d04efa
commit 4286fdbabb
3 changed files with 14 additions and 7 deletions

View File

@ -44,7 +44,7 @@ Token::~Token()
}
void Token::str(const char s[])
void Token::str(const std::string &s)
{
_str = s;
_isName = bool(_str[0] == '_' || std::isalpha(_str[0]));
@ -57,6 +57,11 @@ void Token::str(const char s[])
_varId = 0;
}
void Token::str(const char s[])
{
str(std::string(s));
}
void Token::concatStr(std::string const& b)
{
_str.erase(_str.length() - 1);

View File

@ -26,6 +26,8 @@ class Token
public:
Token();
~Token();
void str(const std::string &s);
void str(const char s[]);
void concatStr(std::string const& b);

View File

@ -104,7 +104,7 @@ void Tokenizer::addtoken(const char str[], const unsigned int lineno, const unsi
{
_tokens = new Token;
_tokensBack = _tokens;
_tokensBack->str(str2.str().c_str());
_tokensBack->str(str2.str());
}
_tokensBack->linenr(lineno);
@ -1257,7 +1257,7 @@ void Tokenizer::simplifyTokenList()
{
std::ostringstream str;
str << SizeOfType(tok->strAt(2));
tok->str(str.str().c_str());
tok->str(str.str());
for (int i = 0; i < 3; i++)
{
@ -1279,7 +1279,7 @@ void Tokenizer::simplifyTokenList()
{
std::ostringstream str;
str << size;
tok->str(str.str().c_str());
tok->str(str.str());
for (int i = 0; i < 3; i++)
{
tok->deleteNext();
@ -1307,7 +1307,7 @@ void Tokenizer::simplifyTokenList()
{
std::ostringstream ostr;
ostr << sz;
tok->str(ostr.str().c_str());
tok->str(ostr.str());
while (tok->next()->str() != ")")
tok->deleteNext();
tok->deleteNext();
@ -1356,7 +1356,7 @@ void Tokenizer::simplifyTokenList()
{
std::ostringstream str;
str << total_size;
tok2->str(str.str().c_str());
tok2->str(str.str());
// Delete the other tokens..
for (int i = 0; i < 3; i++)
{
@ -2334,7 +2334,7 @@ bool Tokenizer::simplifyIfNot()
if (Token::Match(tok, "%var% == 0"))
{
tok->deleteNext();
tok->next()->str(tok->str().c_str());
tok->next()->str(tok->str());
tok->str("!");
ret = true;
}