Open Chronophylos opened 4 years ago
Using a hashmap like
std::unordered_map<std::string, std::function<int(char** argv, int argc, std::string fileName)> fn>
is a lot more performant than comparing strings with strcmp in a giant if-else-block.
strcmp
Or a more simple solution
enum Functions { Open, Close, Write \* ... *\ }; std::unordered_map<std::string, Function> function_map;
Thanks, I think it will do for our simple case, until we have hundreds of functions perhaps.
Using a hashmap like
is a lot more performant than comparing strings with
strcmp
in a giant if-else-block.Or a more simple solution