develooper Front page | perl.perl5.porters | Postings from June 2011

unify pp_eq, pp_ne, pp_cmp etc?

Thread Next
From:
Dave Mitchell
Date:
June 14, 2011 08:49
Subject:
unify pp_eq, pp_ne, pp_cmp etc?
Message ID:
20110614154915.GI2877@iabyn.com
There are a whole bunch of numeric comparison ops, that have very similar,
but quite complex bodies, to cope with IV verses UV verses NV etc.

I was wondering whether it would be beneficial to just replace them all
with thin wrappers around a new function, do_ncmp(), which does
essentially what pp_ncmp() does now.

So for example, pp_eq, would end up looking something like:

    PP(pp_eq)
    {
	dVAR; dSP;
	int res;
	tryAMAGICbin_MG(eq_amg, AMGf_set|AMGf_numeric);
	res = do_cmp(TOPs, POPs);
	SETs(boolSV(res == 0));
    }

Whether the slight inefficiency of using a more general function would be
matched by the code (and thus cache) reuse, I have no idea. I also don't
yet know whether the specific ops handle edge cases more thoroughly than
the more general pp_cmp.

-- 
Lady Nancy Astor: If you were my husband, I would flavour your coffee
with poison.
Churchill: Madam - if I were your husband, I would drink it.

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