develooper Front page | perl.perl5.porters | Postings from July 2004

Re: optimizing Short circuiting sort method based on [M]

From:
Dave Mitchell
Date:
July 9, 2004 03:39
Subject:
Re: optimizing Short circuiting sort method based on [M]
Message ID:
20040709104632.GA1864@iabyn.com
On Thu, Jul 08, 2004 at 08:35:49PM -0500, david nicol wrote:
> There's some reverse-handling code in pp_sort which I took
> to be responding to a hint that
> 
> 	reverse sort ...
> 
> has been encountered:
> 
> 
>             if (PL_op->op_private & OPpSORT_REVERSE) {
>                 SV **p = sorting_av ? AvARRAY(av) : ORIGMARK+1;
>                 SV **q = p+max-1;
>                 while (p < q) {
>                     SV *tmp = *p;
>                     *p++ = *q;
>                     *q-- = tmp;
>                 }
>             }


No, that's for optimising away the sort block in

    @x = sort {$b cmp $a } @y;
    
-- 
Technology is dominated by two types of people: those who understand what
they do not manage, and those who manage what they do not understand. 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About