laziness, impatience, and hubris | |
PerlMonks |
Re: When should I use a dispatch table?by traveler (Parson) |
on Nov 30, 2006 at 23:37 UTC ( [id://587080]=note: print w/replies, xml ) | Need Help?? |
I was pretty surprised by this, too. I have comments on your test, and then a theory. First the comments:
The values in @find are integers, but in the if_else comparison tree, you test for string equality. Testing the hash for existance of a key first, seems wasteful. It might be faster if you did an eval and only acted on failure in that case. Of course, I haven't benched that, yet. My theory: maybe, just maybe, perl does the thing C used to (and maybe still does) and and builds if-else chains into a hash table for evaluation. Dunno. --traveler
In Section
Meditations
|
|