From: Brandon L Black Date: Sat, 21 Apr 2007 16:00:13 +0000 (+0000) Subject: another little optimization X-Git-Tag: 0.07~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f4b986039f6a4af27b3bb385b9b524ba79374b9f;p=gitmo%2FAlgorithm-C3.git another little optimization --- diff --git a/lib/Algorithm/C3.pm b/lib/Algorithm/C3.pm index ec9363c..66c32ff 100644 --- a/lib/Algorithm/C3.pm +++ b/lib/Algorithm/C3.pm @@ -70,10 +70,8 @@ sub merge { # http://www.python.org/2.3/mro.html :) # Initial set (make sure everything is copied - it will be modded) - my @seqs; - foreach (@$recurse_mergeout, $current_parents) { - push(@seqs, [@$_]) if @$_; - } + my @seqs = map { [@$_] } @$recurse_mergeout; + push(@seqs, [@$current_parents]) if @$current_parents; # Construct the tail-checking hash (actually, it's cheaper and still # correct to re-use it throughout this function) @@ -124,7 +122,7 @@ sub merge { ($current_root, $current_parents, $recurse_mergeout, $i) = @{pop @STACK}; - push(@$recurse_mergeout, $mergeout); + push(@$recurse_mergeout, $mergeout) if @$mergeout; } }