What is more efficient a switch case or an std::map

前端 未结 6 1090
星月不相逢
星月不相逢 2020-12-28 13:57

I\'m thinking about the tokenizer here.
Each token calls a different function inside the parser.
What is more efficient:

  • A map of std::functions/boos
6条回答
  •  盖世英雄少女心
    2020-12-28 14:38

    You don't say what type your tokens are. If they are not integers, you don't have a choice - switches only work with integer types.

提交回复
热议问题