I\'m thinking about the tokenizer here.
Each token calls a different function inside the parser.
What is more efficient:
The C++ standard says nothing about the performance of its requirements, only that the functionality should be there.
These sort of questions about which is better or faster or more efficient are meaningless unless you state which implementation you're talking about. For example, the string handling in a certain version of a certain implementation of JavaScript was atrocious, but you can't extrapolate that to being a feature of the relevant standard.
I would even go so far as to say it doesn't matter regardless of the implementation since the functionality provided by switch
and std::map
is different (although there's overlap).
These sort of micro-optimizations are almost never necessary, in my opinion.