If you have a long list of arguments, it will be.
First of all evals don't cost much more than just having
had that much code in the first place. Secondly all of
the evals take place up front. So it is just like having
a longer program.
But at runtime I have a hash lookup (constant time no
matter how large the hash is) rather than repeated tests,
So I have traded compile time away for faster run-time
behaviour.
FWIW I first realized the importance of this win when
trying to speed up a program that categorized states into
ACLI regions for a huge amount of text information. Just
moving the logic out of if/elsif/elsif/else type constructs
into hash lookups and/or smart REs was an order of magnitude
improvement.
Cheers,
Ben |