Commit 7b8f3f25 by Maarten L. Hekkelman

optimise retract buffer

parent 96a67b23
......@@ -257,7 +257,7 @@ class sac_parser
CIFToken m_lookahead;
std::string m_token_value;
CIFValue mTokenType;
std::stack<int> m_buffer;
std::string m_buffer; // retract buffer, used to be a stack<char>
};
// --------------------------------------------------------------------
......
......@@ -68,8 +68,8 @@ int sac_parser::get_next_char()
result = m_source.get();
else
{
result = m_buffer.top();
m_buffer.pop();
result = m_buffer.back();
m_buffer.pop_back();
}
// very simple CR/LF translation into LF
......@@ -77,11 +77,11 @@ int sac_parser::get_next_char()
{
int lookahead = m_source.get();
if (lookahead != '\n')
m_buffer.push(lookahead);
m_buffer.push_back(lookahead);
result = '\n';
}
m_token_value += static_cast<char>(result);
m_token_value.push_back(static_cast<char>(result));
if (result == '\n')
++m_line_nr;
......@@ -106,7 +106,7 @@ void sac_parser::retract()
if (ch == '\n')
--m_line_nr;
m_buffer.push(ch);
m_buffer.push_back(ch);
m_token_value.pop_back();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment