infnan: in pack, first test for the unlikely infnan-ness.
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 25 Sep 2014 14:47:14 +0000 (10:47 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 25 Sep 2014 16:05:16 +0000 (12:05 -0400)
Also make the type I32, not char.

pp_pack.c

index aa3e790..7928315 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -2167,13 +2167,16 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
         fromstr = PEEKFROM;
         if (SvNOK(fromstr)) {
             const NV nv = SvNV(fromstr);
-            const char c = TYPE_NO_MODIFIERS(datumtype);
-            if (Perl_isinfnan(nv) && !strchr("fdFD", c)) {
-                if (c == 'w')
-                    Perl_croak(aTHX_ "Cannot compress %"NVgf" in pack", nv);
-                else
-                    Perl_croak(aTHX_ "Cannot pack %"NVgf" with '%c'",
-                               nv, (int) c);
+            if (UNLIKELY(Perl_isinfnan(nv))) {
+                const I32 c = TYPE_NO_MODIFIERS(datumtype);
+                if (!strchr("fdFD", (char)c)) { /* floats are okay */
+                    if (c == 'w')
+                        Perl_croak(aTHX_
+                                   "Cannot compress %"NVgf" in pack", nv);
+                    else
+                        Perl_croak(aTHX_ "Cannot pack %"NVgf" with '%c'",
+                                   nv, (int) c);
+                }
             }
         }