pp_ctl.c:pp_flop: Avoid redundant SvNV calls
authorFather Chrysostomos <sprout@cpan.org>
Sun, 25 Aug 2013 08:30:18 +0000 (01:30 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 25 Aug 2013 13:41:15 +0000 (06:41 -0700)
Calling SvNV on an SV that is IOK is unnecessary, and results in an
extra function call if the SV is not NOKp.  If an NV is out of range
and has been used as an int, it will be IOKp but not IOK.

pp_ctl.c

index 2bed58c..6cb26bd 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1230,8 +1230,10 @@ PP(pp_flop)
        if (RANGE_IS_NUMERIC(left,right)) {
            IV i, j;
            IV max;
-           if ((SvOK(left) && SvNV_nomg(left) < IV_MIN) ||
-               (SvOK(right) && SvNV_nomg(right) > IV_MAX))
+           if ((SvOK(left) && !SvIOK(left) && SvNV_nomg(left) < IV_MIN) ||
+               (SvOK(right) && (SvIOK(right)
+                                ? SvIsUV(right) && SvUV(right) > IV_MAX
+                                : SvNV_nomg(right) > IV_MAX)))
                DIE(aTHX_ "Range iterator outside integer range");
            i = SvIV_nomg(left);
            max = SvIV_nomg(right);