summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2011-06-21 17:32:20 +0100
committerDavid Mitchell <davem@iabyn.com>2011-06-25 09:28:17 +0100
commit06c6da524f9e0eae167367edc8fe0150d69893fa (patch)
treeb9a92d58f96cb001095ea01f19933e7111c6a6e6
parent69cb655bad9945c212e3b4016966ad8d90dfae8a (diff)
downloadperl-06c6da524f9e0eae167367edc8fe0150d69893fa.tar.gz
pp_ncmp: favour the non- Perl_isnan route
Currently pp_ncmp(), when comparing two NVs, prefers to check its two args for NaNness first, and if either of them are, then return undef. Only if Perl_isnan isn't defined does it fall back to doing three compares (<, >, =) where if all three fail it returns undef. This is in contrast to the other compare functions (e.g. pp_lt), which only use Perl_isnan if NAN_COMPARE_BROKEN is defined - i.e. they prefer to rely on the '<' (or whatever) test to handle NaNs implicitly. Change pp_ncmp to favour not using Perl_isnan(). This has two advantages: First, speed: in the normal case we replace: two function calls to Perl_isnan plus two comparisons, with: three comparisons. Second, this makes pp_ncmp more similar to the other comparison functions, allowing for code reuse in the future.
-rw-r--r--pp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index 2cbbfddbdc..997b5ba783 100644
--- a/pp.c
+++ b/pp.c
@@ -2439,7 +2439,7 @@ PP(pp_ncmp)
dPOPTOPnnrl_nomg;
I32 value;
-#ifdef Perl_isnan
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
if (Perl_isnan(left) || Perl_isnan(right)) {
SETs(&PL_sv_undef);
RETURN;