in reply to When should I use a dispatch table?
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: When should I use a dispatch table?
by runrig (Abbot) on Dec 01, 2006 at 00:04 UTC | |
by Limbic~Region (Chancellor) on Dec 01, 2006 at 00:28 UTC | |
by runrig (Abbot) on Dec 01, 2006 at 07:21 UTC | |
by friedo (Prior) on Dec 01, 2006 at 00:26 UTC | |
Re^2: When should I use a dispatch table?
by Limbic~Region (Chancellor) on Nov 30, 2006 at 23:46 UTC | |
by traveler (Parson) on Nov 30, 2006 at 23:53 UTC | |
by Limbic~Region (Chancellor) on Dec 01, 2006 at 00:18 UTC |