From: Brandon L Black Date: Sat, 21 Apr 2007 15:03:40 +0000 (+0000) Subject: oops, I was testing with the wrong perl earlier, reverted one optimization that does... X-Git-Tag: 0.07~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f31aa6f69e6dfa26c5edad4e31dbbeebebc55318;p=gitmo%2FAlgorithm-C3.git oops, I was testing with the wrong perl earlier, reverted one optimization that does not work on 5.8.x, and added a new one that does --- diff --git a/lib/Algorithm/C3.pm b/lib/Algorithm/C3.pm index a5754a1..ec9363c 100644 --- a/lib/Algorithm/C3.pm +++ b/lib/Algorithm/C3.pm @@ -26,7 +26,7 @@ sub merge { my $i = 0; my %seen = ( $root => 1 ); - my ($new_root, $mergeout, $seq); + my ($new_root, $mergeout, %tails); while(1) { if($i < @$current_parents) { $new_root = $current_parents->[$i++]; @@ -75,9 +75,9 @@ sub merge { push(@seqs, [@$_]) if @$_; } - # Construct the tail-checking hash - my %tails; - foreach $seq (@seqs) { + # Construct the tail-checking hash (actually, it's cheaper and still + # correct to re-use it throughout this function) + foreach my $seq (@seqs) { $tails{$seq->[$_]}++ for (1..$#$seq); }