deque vs istringstream

I am developing a small scripting language in C++ as a project. I am currently working on the Lexer and have a few concerns about overhead. Right now I am scanning the entire source file using a file stream. I am using a deque as the
container for each character read from the file.

I have developed an interface for the Lexer that performs typical operations such as: peek(), next(), scanLiteral(), scanWord(), skipComment(), etc.

I realized however that a istringstream provides similar functionality. I want to
make sure that as I read characters and evaluate them that popping them isn't less efficient than shifting through a stream.
They both increment an internal counter. There are no expensive operations such as memory deallocation involved.
std::deque does have the advantage of allowing you to see further than the top, though.
Last edited on
Topic archived. No new replies allowed.