use 5.xxx: Don’t load feature.pm unnecessarily
authorFather Chrysostomos <sprout@cpan.org>
Wed, 7 Dec 2011 05:33:18 +0000 (21:33 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 7 Dec 2011 14:15:35 +0000 (06:15 -0800)
And don’t look in the hint hash unless the LOCALIZE_HH hint is set.

op.c

diff --git a/op.c b/op.c
index 6bdde58..718f0e6 100644 (file)
--- a/op.c
+++ b/op.c
@@ -4670,12 +4670,18 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *idop, OP *arg)
 
     if (use_version) {
        HV * const hinthv = GvHV(PL_hintgv);
+       const bool hhoff = !hinthv || !(PL_hints & HINT_LOCALIZE_HH);
 
        /* Turn features off */
-       ENTER_with_name("load_feature");
-       Perl_load_module(aTHX_
-           PERL_LOADMOD_DENY, newSVpvs("feature"), NULL, NULL
-       );
+       if (hhoff)
+           /* avoid loading feature.pm */
+           PL_hints &= ~HINT_UNI_8_BIT;
+       else {
+           ENTER_with_name("load_feature");
+           Perl_load_module(aTHX_
+               PERL_LOADMOD_DENY, newSVpvs("feature"), NULL, NULL
+           );
+       }
 
        /* If we request a version >= 5.9.5, load feature.pm with the
         * feature bundle that corresponds to the required version. */
@@ -4684,27 +4690,29 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *idop, OP *arg)
        if (vcmp(use_version,
                 sv_2mortal(upg_version(newSVnv(5.009005), FALSE))) >= 0) {
            SV *const importsv = vnormal(use_version);
+           if (hhoff) ENTER_with_name("load_feature");
            *SvPVX_mutable(importsv) = ':';
            Perl_load_module(aTHX_ 0, newSVpvs("feature"), NULL, importsv, NULL);
+           LEAVE_with_name("load_feature");
        }
-       LEAVE_with_name("load_feature");
+       else if (!hhoff) LEAVE_with_name("load_feature");
        /* If a version >= 5.11.0 is requested, strictures are on by default! */
        if (vcmp(use_version,
                 sv_2mortal(upg_version(newSVnv(5.011000), FALSE))) >= 0) {
-           if (!hinthv || !hv_exists(hinthv, "strict/refs", 11))
+           if (hhoff || !hv_exists(hinthv, "strict/refs", 11))
                PL_hints |= HINT_STRICT_REFS;
-           if (!hinthv || !hv_exists(hinthv, "strict/subs", 11))
+           if (hhoff || !hv_exists(hinthv, "strict/subs", 11))
                PL_hints |= HINT_STRICT_SUBS;
-           if (!hinthv || !hv_exists(hinthv, "strict/vars", 11))
+           if (hhoff || !hv_exists(hinthv, "strict/vars", 11))
                PL_hints |= HINT_STRICT_VARS;
        }
        /* otherwise they are off */
        else {
-           if (!hinthv || !hv_exists(hinthv, "strict/refs", 11))
+           if (hhoff || !hv_exists(hinthv, "strict/refs", 11))
                PL_hints &= ~HINT_STRICT_REFS;
-           if (!hinthv || !hv_exists(hinthv, "strict/subs", 11))
+           if (hhoff || !hv_exists(hinthv, "strict/subs", 11))
                PL_hints &= ~HINT_STRICT_SUBS;
-           if (!hinthv || !hv_exists(hinthv, "strict/vars", 11))
+           if (hhoff || !hv_exists(hinthv, "strict/vars", 11))
                PL_hints &= ~HINT_STRICT_VARS;
        }
     }