op.c: Use new feature bundle hints
authorFather Chrysostomos <sprout@cpan.org>
Fri, 23 Dec 2011 06:22:51 +0000 (22:22 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 24 Dec 2011 17:25:18 +0000 (09:25 -0800)
Now ‘use v5.22’ and ‘use 5.005’ no longer have to load feature.pm
to enable the current feature bundle.  All they do is twiddle bits
in PL_hints.

Since version declarations no longer call feature->unimport, there
may be junk left over in %^H (which we leave for speed’s sake), so
feature.pm has to delete that junk before enabling features.

lib/feature.pm
op.c
regen/feature.pl

index c9e188b..75c6666 100644 (file)
@@ -299,7 +299,11 @@ sub import {
         croak("No features specified");
     }
     if (my $features = current_bundle) {
-       # Features are enabled implicitly via bundle hints
+       # Features are enabled implicitly via bundle hints.
+
+       # Delete any keys that may be left over from last time.
+       delete @^H{ values(%feature) };
+
        unshift @_, @$features;
        $^H |= $hint_mask;
     }
diff --git a/op.c b/op.c
index 941da4f..d5b039c 100644 (file)
--- a/op.c
+++ b/op.c
@@ -4672,26 +4672,12 @@ 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);
-       SV *importsv;
 
-       /* Turn features off */
-       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
+       /* Enable the
         * feature bundle that corresponds to the required version. */
        use_version = sv_2mortal(new_version(use_version));
+       S_enable_feature_bundle(aTHX_ use_version);
 
-       if (vcmp(use_version,
-                sv_2mortal(upg_version(newSVnv(5.009005), FALSE))) >= 0) {
-           importsv = vnormal(use_version);
-           *SvPVX_mutable(importsv) = ':';
-       }
-       else importsv = newSVpvs(":default");
-       Perl_load_module(aTHX_ 0, newSVpvs("feature"), NULL, importsv, NULL);
-       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) {
index 2763d09..cbf4db8 100755 (executable)
@@ -567,7 +567,11 @@ sub import {
         croak("No features specified");
     }
     if (my $features = current_bundle) {
-       # Features are enabled implicitly via bundle hints
+       # Features are enabled implicitly via bundle hints.
+
+       # Delete any keys that may be left over from last time.
+       delete @^H{ values(%feature) };
+
        unshift @_, @$features;
        $^H |= $hint_mask;
     }