Petr Baudis wrote: > Dear diary, on Tue, Jun 20, 2006 at 06:51:18PM CEST, I got a letter > where Jakub Narebski <jnareb@xxxxxxxxx> said that... >> * Refactor dispatch from if...elsif...else construction >> to using 'name' => \&sub hash. > > In other words, you say the result of the IRC discussion we had about > symbol lookups and evals turned out really scary? ;-) First, we need arrays (ordering!) of sets of possible actions for navbar, so we will have list of all possible actions. Besides, simple test [...] sub dispatch { dispatch_ifelse(@_); #dispatch_hash(@_); #dispatch_callname(@_); #dispatch_anonsub(@_); } sub test_dispatch_all { dispatch(undef); dispatch("summary"); [...] dispatch("tag"); dispatch("unknown"); dispatch("tag();injected();"); } test_dispatch_all() foreach (1..10000); run with '$ time ./test.pl > /dev/null' has shown that (suprise, suprise!) that hash is fastest, then if...elsif...else variant, then my $sub = \&{"git_$action"}; eval { &$sub() }; and last, much much worse is eval "..." version. Of course test leaves something to be desired... -- Jakub Narebski Warsaw, Poland ShadeHawk on #git - : send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html