From 447c830e8fe6489bf577a5585eaa9bafc7755c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 28 Mar 2009 20:33:55 +0100 Subject: [PATCH] performance enhancement (patch submitted by davidmiller in ticket 231) --- src/token.cpp | 6 ++++++ src/token.h | 2 ++ src/tokenize.cpp | 5 +---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/token.cpp b/src/token.cpp index 33883f9ed..68b9450c8 100644 --- a/src/token.cpp +++ b/src/token.cpp @@ -58,6 +58,12 @@ void Token::str(const char s[]) _varId = 0; } +void Token::concatStr(std::string const& b) +{ + _str.erase(_str.length() - 1); + _str.append(b.begin() + 1, b.end()); +} + void Token::deleteNext() { Token *n = _next; diff --git a/src/token.h b/src/token.h index 6824a4825..743425cb3 100644 --- a/src/token.h +++ b/src/token.h @@ -29,6 +29,8 @@ public: ~Token(); void str(const char s[]); + void concatStr(std::string const& b); + const std::string &str() const { return _str; diff --git a/src/tokenize.cpp b/src/tokenize.cpp index ee8d99260..4d15642cc 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -811,10 +811,7 @@ void Tokenizer::simplifyTokenList() while (tok->str()[0] == '"' && tok->next() && tok->next()->str()[0] == '"') { // Two strings after each other, combine them - std::string temp = tok->str(); - temp.erase(temp.length() - 1); - temp.append(tok->next()->str().substr(1)); - tok->str(temp.c_str()); + tok->concatStr(tok->next()->str()); tok->deleteNext(); } }