From: Robin Houston Date: Tue, 1 May 2001 14:07:12 +0000 (+0100) Subject: optimised sort X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7e80da18e775cb5cc203f20486bcf5f748ca193a;p=p5sagit%2Fp5-mst-13.2.git optimised sort Message-ID: <20010501140712.A4266@penderel> p4raw-id: //depot/perl@9927 --- diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index c448fd6..6e42a48 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -13,7 +13,8 @@ use B qw(class main_root main_start main_cv svref_2object opnumber cstring OPf_KIDS OPf_REF OPf_STACKED OPf_SPECIAL OPpLVAL_INTRO OPpENTERSUB_AMPER OPpSLICE OPpCONST_BARE OPpTRANS_SQUASH OPpTRANS_DELETE OPpTRANS_COMPLEMENT OPpTARGET_MY - OPpCONST_ARYBASE OPpEXISTS_SUB + OPpCONST_ARYBASE OPpEXISTS_SUB OPpSORT_NUMERIC OPpSORT_INTEGER + OPpSORT_REVERSE SVf_IOK SVf_NOK SVf_ROK SVf_POK CVf_METHOD CVf_LOCKED CVf_LVALUE PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE PMf_SKIPWHITE @@ -2095,6 +2096,13 @@ sub indirop { $indir = $indir . " "; $kid = $kid->sibling; } + if ($name eq "sort" && $op->private & (OPpSORT_NUMERIC | OPpSORT_INTEGER)) { + $indir = ($op->private & OPpSORT_REVERSE) ? '{$b <=> $a} ' + : '{$a <=> $b} '; + } + elsif ($name eq "sort" && $op->private & OPpSORT_REVERSE) { + $indir = '{$b cmp $a} '; + } for (; !null($kid); $kid = $kid->sibling) { $expr = $self->deparse($kid, 6); push @exprs, $expr;