3 ms·
You either need that giant switch or checks at every use anyway in order to protect yourself against bad data. Better yet would be an explicit mapping of number
by account42 2y ago
You either need that giant switch or checks at every use anyway in order to protect yourself against bad data. Better yet would be an explicit mapping of numbers in the file and enum values so that your file format and runtime enum are decoupled. The compiler can still optimize that into a simple range check when the values match up.