Given a series of commands and very unique code that must be run for each:
if(cmd == "cmd.setBoosterRocket")
...
else if(cmd == "cmd.windSales")
...
else if(cmd == "cmd.selfDustruct")
...
else if(cmd == "cmd.unleashHounds")
...
How might this be optimized? Be put into a switch statement, that is?
I considered making a vector of hashes:
std::hash<std::string> hasher;
for(std::string command : m_commandList)
m_mashes.push_back(hasher(command)
But a vector cannot be accessed as part of a switch case statement as it is not a constexpr. The list of string commands is known at compile time, and I could potentially hardcode the hash values...but that does not seem like a great idea.