diff --git a/simplecpp.cpp b/simplecpp.cpp index 7c4a6c4d..96c9d31b 100755 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -1362,14 +1362,18 @@ std::string simplecpp::TokenList::lastLine(int maxsize) const if (++count > maxsize) return ""; if (!ret.empty()) - ret.insert(0, 1, ' '); + ret += ' '; + // add tokens in reverse for performance reasons if (tok->str()[0] == '\"') - ret.insert(0, "%str%"); + ret += "%rts%"; // %str% else if (tok->number) - ret.insert(0, "%num%"); - else - ret.insert(0, tok->str()); + ret += "%mun%"; // %num% + else { + ret += tok->str(); + std::reverse(ret.end() - tok->str().length(), ret.end()); + } } + std::reverse(ret.begin(), ret.end()); return ret; }