Re: [RFC] gitweb wishlist and TODO list
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Jun 20, 2006, 20:59 UTC
- Message-ID
- <e79njs$hue$1@sea.gmane.org>
- In-Reply-To
- <20060620201035.GT2609@pasky.or.cz>
Petr Baudis wrote:
> Dear diary, on Tue, Jun 20, 2006 at 06:51:18PM CEST, I got a letter > where Jakub Narebski <jnareb@gmail.com> said that...
Show 5 quoted lines
>> * 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