Browse Source

Util: Optimize Lexer::getNumberOrLiteral() to one string append

master
Riyyi 2 years ago
parent
commit
9f31a04909
  1. 9
      src/util/json/lexer.cpp

9
src/util/json/lexer.cpp

@ -196,8 +196,8 @@ bool Lexer::getString()
bool Lexer::getNumberOrLiteral(Token::Type type) bool Lexer::getNumberOrLiteral(Token::Type type)
{ {
size_t index = m_index;
size_t column = m_column; size_t column = m_column;
std::string symbol = "";
std::string breakOnCharacter = std::string("{}[]:,") + '"' + ' ' + '\t' + '\r' + '\n' + '\0'; std::string breakOnCharacter = std::string("{}[]:,") + '"' + ' ' + '\t' + '\r' + '\n' + '\0';
for (char character;;) { for (char character;;) {
@ -207,12 +207,13 @@ bool Lexer::getNumberOrLiteral(Token::Type type)
break; break;
} }
symbol += character;
increment(); increment();
} }
decrement();
m_tokens->push_back({ type, m_line, column, symbol }); m_tokens->push_back({ type, m_line, column,
m_job->input().substr(index, m_index - index) });
decrement();
return true; return true;
} }

Loading…
Cancel
Save