Commit 7b8f3f25 by Maarten L. Hekkelman

optimise retract buffer

parent 96a67b23
...@@ -257,7 +257,7 @@ class sac_parser ...@@ -257,7 +257,7 @@ class sac_parser
CIFToken m_lookahead; CIFToken m_lookahead;
std::string m_token_value; std::string m_token_value;
CIFValue mTokenType; 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() ...@@ -68,8 +68,8 @@ int sac_parser::get_next_char()
result = m_source.get(); result = m_source.get();
else else
{ {
result = m_buffer.top(); result = m_buffer.back();
m_buffer.pop(); m_buffer.pop_back();
} }
// very simple CR/LF translation into LF // very simple CR/LF translation into LF
...@@ -77,11 +77,11 @@ int sac_parser::get_next_char() ...@@ -77,11 +77,11 @@ int sac_parser::get_next_char()
{ {
int lookahead = m_source.get(); int lookahead = m_source.get();
if (lookahead != '\n') if (lookahead != '\n')
m_buffer.push(lookahead); m_buffer.push_back(lookahead);
result = '\n'; result = '\n';
} }
m_token_value += static_cast<char>(result); m_token_value.push_back(static_cast<char>(result));
if (result == '\n') if (result == '\n')
++m_line_nr; ++m_line_nr;
...@@ -106,7 +106,7 @@ void sac_parser::retract() ...@@ -106,7 +106,7 @@ void sac_parser::retract()
if (ch == '\n') if (ch == '\n')
--m_line_nr; --m_line_nr;
m_buffer.push(ch); m_buffer.push_back(ch);
m_token_value.pop_back(); 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