- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
um...if youre going to hash, why not have a hash table that contains function pointers? or can you not do that in this language?
Admin
The really sensible way to do this if you're going to be doing something non trivial with command line parsing is to use an existing class to do it, or write your own (it isn't hard). Really, the only constraint on this sort of code is that it should be easy to maintain. Even if it runs in exponential time it isn't particularly significant. How long do you think it takes for the VM to start up? In other words, you're an idiot if you think the parse code is even worth thinking about in terms of performance. Robustness and maintainability are good things to think about. Worrying whether stringcmp is faster than a mersenne twsister like hash is not really relevant.
Admin
Admin
I think the problem was that two strings with non-identical hashes could, conceivably, have identical hashes if one were misspelled. Let's say you had an option --list for listing the contents of your database, and --delete for deleting from it. Let's further say that "--lsit" or "---list" or "-list" hashes to the same thing as "--delete", even though "--list" (the value in the switch) doesn't, so all the listed switch values are distinct.
If that were the case, then a simple typo (which should be rejected) would have unintended negative consequences. True, it's incredibly improbable, but definitely not impossible.
Admin
Appearently "j(NQ, iGNQ, hfNQ, iFmQ, hemQ, j'mQ, j)/Q, iH/Q, hg/Q, j(O2, iGO2, hfO2, j)02, iH02, hg02, iFn2, hen2, j'n2, j(Mp, iGMp, hfMp, iFlp, help, j'lp, j).p, iH.p, hg.p" all have the same hashcodes under Java.
Addendum (2010-09-11 15:11): By the way, on the subject of "multi", these also all have the same hashcode: "nWNW+, o8NW+, mvNW+, nVmW+, o7mW+, mumW+, nX/W+, o9/W+, mw/W+, nWO8+, o8O8+, mvO8+, nX08+, o908+, mw08+, nVn8+, o7n8+, mun8+, nWMv+, o8Mv+, mvMv+, nVlv+, o7lv+, mulv+, nX.v+, o9.v+, mw.v+, nWNVJ, o8NVJ, mvNVJ, nVmVJ, o7mVJ, mumVJ, nX/VJ, o9/VJ, mw/VJ, nWO7J, o8O7J, mvO7J, nX07J, o907J, mw07J, nVn7J, o7n7J, mun7J, nWMuJ, o8MuJ, mvMuJ, nVluJ, o7luJ, muluJ, nX.uJ, o9.uJ, mw.uJ, nWNUi, o8NUi, mvNUi, nVmUi, o7mUi, mumUi, nX/Ui, o9/Ui, mw/Ui, nWO6i, o8O6i, mvO6i, nX06i, o906i, mw06i, nVn6i, o7n6i, mun6i, nWMti, o8Mti, mvMti, nVlti, o7lti, multi, nX.ti, o9.ti, mw.ti"
Admin
Hello Guys, Glad to Join! :)