Misguided Optimization
by Mark Bowytz
in CodeSOD
on 2014-08-20
States and their abbreviations are among my favorite kinds of data - they almost never ever change and, as such, you can hard code all that information into your app. I mean, why bother fetching it from the database every page load? That's just wasted CPU cycles.
So, I can find merit in the hard-coded approach that the below code takes that Alex E. sent our way. However, I definitely believe that it takes guts for anybody to make a claim about the efficiency of strcmp() when you perform a linear search on an ordered list.