From: Vincent Pit Date: Mon, 3 Nov 2008 08:30:30 +0000 (+0100) Subject: Remove the dispatch table in flatten() X-Git-Tag: v0.09~15 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FSub-Prototype-Util.git;a=commitdiff_plain;h=8475b0d17d26abf108ef898393e2b7e3adc61cca Remove the dispatch table in flatten() --- diff --git a/lib/Sub/Prototype/Util.pm b/lib/Sub/Prototype/Util.pm index 91520b8..c5c6ffd 100644 --- a/lib/Sub/Prototype/Util.pm +++ b/lib/Sub/Prototype/Util.pm @@ -72,14 +72,18 @@ sub flatten { if ($1) { my $a = shift; my $r = _check_ref $a, $p; - my %deref = ( - SCALAR => sub { push @args, $$a }, - ARRAY => sub { push @args, @$a }, - HASH => sub { push @args, %$a }, - GLOB => sub { push @args, *$a }, - CODE => sub { push @args, &$a } - ); - $deref{$r}->(); + push @args, $r eq 'SCALAR' + ? $$a + : ($r eq 'ARRAY' + ? @$a + : ($r eq 'HASH' + ? %$a + : ($r eq 'GLOB' + ? *$a + : &$a # _check_ref ensures this must be a code ref + ) + ) + ); } elsif ($p =~ /[\@\%]/) { push @args, @_; last;