develooper Front page | perl.perl5.porters | Postings from September 2016

Re: [PATCH] fix sorting with custom subroutines returning bignumbers

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
September 29, 2016 08:54
Subject:
Re: [PATCH] fix sorting with custom subroutines returning bignumbers
Message ID:
20160929085419.GN3193@iabyn.com
On Fri, Jan 15, 2016 at 12:26:46PM +0100, Salvador Fandiño wrote:
> The return value of the comparison subroutine is converted into an NV
> which is able to store with enough precision the sign of any number
> representation used natively by perl.
> 
> Then the resulting NV is converted into -1, 0 or 1.

Sorry, your patch seems to have fallen through the cracks.

Having reviewed it though, I'm not happy with the idea of every sort
comparison result being converted to an NV and then to an I32 (via
comparisons), which will slow down every sort comparison, given that
the overwhelming majority of sort comparisons will return an SvIOK()
value.

I think probably a better approach would be to change SVCOMPARE_t to be a
function that returns an IV rather than an I32, then fix up all such
functions and the callers of such functions, to be IV. Then the
'IV result = SvIV(*PL_stack_sp)' in places like S_sortcv() will be fast
for normal return values, and correct for large or NV values.

-- 
Music lesson: a symbiotic relationship whereby a pupil's embellishments
concerning the amount of practice performed since the last lesson are
rewarded with embellishments from the teacher concerning the pupil's
progress over the corresponding period.

Thread Previous | Thread Next


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