develooper Front page | perl.perl5.porters | Postings from October 2000

Re: pp_add -> pp_i_add efficiency hack?

Thread Previous | Thread Next
Gurusamy Sarathy
October 5, 2000 09:35
Re: pp_add -> pp_i_add efficiency hack?
Message ID:
On Thu, 05 Oct 2000 12:58:42 BST, Simon Cozens wrote:
>Yup, it dawned on me a few minutes after posting that we can't do much
>else because to discover whether you can use the integer
>addition/subtraction/etc. on, say, C<$a+3> you have to go through the
>whole looks_like_number thing to find out whether C<$a> is really an
>integer or a float. So it would lose anyway. Bletch.

A potential avenue of exploration that I recall mentioning here would 
be to never convert to PVNV unless the NVX slot is being set by the
operation, or if an attempt is being made to read a PV as an NV.  IOW<
an attempt to *read* the NV should never promote if the SV is an IV;
instead it should cast the IVX to NV and return that.  Among other
things, this means making SvNV() do something like this:

    #define SvNV(sv) (SvNOK(sv) ? SvNVX(sv)
                                : (SvIOK(sv) ? (NV)SvIVX(sv) : sv_2nv(sv)))

instead of this:

    #define SvNV(sv) (SvNOK(sv) ? SvNVX(sv) : sv_2nv(sv))

You could try that (embellish it further for UVness) and see where that
takes you performance-wise...


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About