HOME     MENU     SEARCH     NEWSLETTER    
NEWS & INFORMATION FOR TECHNOLOGY PURCHASERS. UPDATED ABOUT A MINUTE AGO.
You are here: Home / Best of the Best: Tech Blog Roundup
Build Apps 5x Faster
For Half the Cost Enterprise Cloud Computing
On Force.com
Home > Tech Blogs  Flag for objectionable content? Flag for Objectionable Content?
Average Rating:
Rate this article:  
The Daily WTF: CodeSOD: Misguided Optimization
2014-08-20 4:31am -07:00T Visit The Daily WTF


Outtake:

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.

const char *StAbbrs[] = {".", "AA", "AB", "AE", "AK", "AL", "AP", "AR",
"AS", "AZ", "BC", "CA", "CI", "CO", "CT", "CZ", "DC", "DE", "FL", "GA",
"GU", "HI", "IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MB", "MD",
"ME", "MI", "MN", "MO", "MP", "MS", "MT", "NB", "NC", "ND", "NE", "NF",
"NH", "NJ", "NM", "NS", "NV", "NY", "OH", "OK", "ON", "OR", "PA", "PE",
"QC", "PR", "RI", "SC", "SD", "SK", "TN", "TX", "US", "UT", "VA", "VI",
 "VT", "WA", "WI", "WV", "WY"};const char *StateNames[] = {"Foreign Address", "Americas", "Alberta",
 "Europe", "Alaska", "Alabama", "Pacific", "Arkansas", "American Samoa",
 "Arizona", "British Columbia", "California", "Cayman Islands",
 "Colorado", "Connecticut", "Canal Zone", "Dist. of Columbia",
 "Delaware", "Florida", "Georgia", "Guam", "Hawaii", "Iowa",...
              

Read More on The Daily WTF...


  © Copyright 2014 The Daily WTF. All rights reserved. If you've enjoyed this content, please visit The Daily WTF to show your appreciation.

Information for Bloggers
 

Latest Blog Entries from The Daily WTF:
Error'd: Error Based Marketing
CodeSOD: XXL XML
The Technobabble Prescription
Announcements: Cleveland TDWTF Meet-up
CodeSOD: Ancient Daze
Latest Tech Blogs from around the Blogosphere:
hack a day: THP Hacker Bio: AKA
Content Digitization QA: Recording from the webinar on “No One Left Behind – Let’s Embrace Accessibility Testing”
Content Digitization QA: Recording from the webinar on “No One Left Behind – Let’s Embrace Accessibility Testing”
Content Digitization QA: Recording from the webinar on “No One Left Behind – Let’s Embrace Accessibility Testing”
Content Digitization QA: Recording from the webinar on “No One Left Behind – Let’s Embrace Accessibility Testing”

NEWSFACTOR.COM
NEWSFACTOR NETWORK SITES
NEWSFACTOR SERVICES
© Copyright 2014 NewsFactor Network, Inc. All rights reserved. Member of Accuserve Ad Network.