summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorTAKAI Kousuke <62541129+t-a-k@users.noreply.github.com>2021-01-27 23:53:48 +0900
committerTony Cook <tony@develop-help.com>2021-09-22 15:59:35 +1000
commit644e3ee3290a8de5f7fc90ae85ae5c96a2a00039 (patch)
tree4db9a8ea95918f08581b222c393b66ed09bdcdff /pp.c
parent23cca2d1f4544cb47f1124d98c308ce1f31f09a6 (diff)
downloadperl-644e3ee3290a8de5f7fc90ae85ae5c96a2a00039.tar.gz
Use fabs/fabsl/fabsq for NVs in pp_abs.
In many floating point formats, fabs*() are rather simple operations such as just clearing the sign bit, and will be slightly faster than a conditional negation (especially with optimizing compilers).
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/pp.c b/pp.c
index d0df828363..8054e7da11 100644
--- a/pp.c
+++ b/pp.c
@@ -3057,10 +3057,7 @@ PP(pp_abs)
}
} else{
const NV value = SvNV_nomg(sv);
- if (value < 0.0)
- SETn(-value);
- else
- SETn(value);
+ SETn(Perl_fabs(value));
}
}
return NORMAL;