]> git.vpit.fr Git - perl/modules/Sub-Prototype-Util.git/commitdiff
Remove the dispatch table in flatten()
authorVincent Pit <vince@profvince.com>
Mon, 3 Nov 2008 08:30:30 +0000 (09:30 +0100)
committerVincent Pit <vince@profvince.com>
Mon, 3 Nov 2008 08:30:30 +0000 (09:30 +0100)
lib/Sub/Prototype/Util.pm

index 91520b823361f417e9d715e1d3f7f63d4888a04e..c5c6ffd94294b2dbb04041e136a765604f107736 100644 (file)
@@ -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;