In perl.git, the branch smoke-me/Deparse-feature-detangle has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/ae0ed4a664771994ed0657565e4930543f524469?hp=010b90a910922b6cf21bb0e5ae0c36ce9b0ff914>

- Log -----------------------------------------------------------------
commit ae0ed4a664771994ed0657565e4930543f524469
Author: Nicholas Clark <[email protected]>
Date:   Tue Feb 28 23:30:30 2012 +0100

    In B::Deparse::_features_from_bundle(), don't call feature::current_bundle()
    
    Instead, directly access feature's package variables, as B::Deparse already
    does in 14 other places. (It also has its tentacles firmly into strict
    and warning's package variables - it's not fussy)
    
    feature::current_bundle() was not part of the documented API of feature
    either, so B::Deparse wasn't clean previously.

M       dist/B-Deparse/Deparse.pm

commit 67796dcf7a535e6fb8dcfb1467e3a802d7452076
Author: Nicholas Clark <[email protected]>
Date:   Tue Feb 28 11:11:02 2012 +0100

    In Deparse, use $feature::hint_mask directly, instead of copying its value.
    
    Also, require feature unconditionally.
    
    Deparse already directly uses data from feature, switch and warnings, so
    this isn't a new trend in encapsulation breakage. Previously Deparse copied
    the value of $feature::hint_mask, and lazily loaded require in 4 places.

M       dist/B-Deparse/Deparse.pm

commit 1fd9cf1d698de217573cd523a125c8b4ebd498d7
Author: Nicholas Clark <[email protected]>
Date:   Tue Feb 28 23:09:02 2012 +0100

    In B::Deparse, refactor common code into _features_from_bundle().

M       dist/B-Deparse/Deparse.pm

commit 764455d648b5ba6c32ab47ed783865304d65a524
Author: Nicholas Clark <[email protected]>
Date:   Tue Feb 28 22:57:31 2012 +0100

    In B::Deparse, refactor the two places that feature::current_bundle()
    
    Converge the code, so that it's easy to extract out into a subroutine.

M       dist/B-Deparse/Deparse.pm
-----------------------------------------------------------------------

Summary of changes:
 dist/B-Deparse/Deparse.pm |   44 ++++++++++++++++++++------------------------
 1 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm
index de768d9..eb24214 100644
--- a/dist/B-Deparse/Deparse.pm
+++ b/dist/B-Deparse/Deparse.pm
@@ -24,6 +24,7 @@ $VERSION = '1.13';
 use strict;
 use vars qw/$AUTOLOAD/;
 use warnings ();
+require feature;
 
 BEGIN {
     # List version-specific constants here.
@@ -1448,7 +1449,13 @@ sub seq_subs {
     return @text;
 }
 
-my $feature_bundle_mask = 0x1c000000;
+sub _features_from_bundle {
+    my ($hints, $hh) = @_;
+    foreach (@{$feature::feature_bundle{@feature::hint_bundles[$hints >> 
$feature::hint_shift]}}) {
+       $hh->{$feature::feature{$_}} = 1;
+    }
+    return $hh;
+}
 
 # Notice how subs and formats are inserted between statements here;
 # also $[ assignments and pragmas.
@@ -1504,22 +1511,17 @@ sub pp_nextstate {
 
     if ($] >= 5.015006) {
        # feature bundle hints
-       my $from = $old_hints & $feature_bundle_mask;
-       my $to   = $    hints & $feature_bundle_mask;
+       my $from = $old_hints & $feature::hint_mask;
+       my $to   = $    hints & $feature::hint_mask;
        if ($from != $to) {
-           require feature;
-           if ($to == $feature_bundle_mask) {
+           if ($to == $feature::hint_mask) {
                if ($self->{'hinthash'}) {
                    delete $self->{'hinthash'}{$_}
                        for grep /^feature_/, keys %{$self->{'hinthash'}};
                }
                else { $self->{'hinthash'} = {} }
-               local $^H = $from;
-               %{$self->{'hinthash'}} = (
-                   %{$self->{'hinthash'}},
-                   map +($feature::feature{$_} => 1),
-                        @{feature::current_bundle()},
-               );
+               $self->{'hinthash'}
+                   = _features_from_bundle($from, $self->{'hinthash'});
            }
            else {
                my $bundle =
@@ -1593,7 +1595,7 @@ my %rev_feature;
 sub declare_hinthash {
     my ($from, $to, $indent, $hints) = @_;
     my $doing_features =
-       ($hints & $feature_bundle_mask) == $feature_bundle_mask;
+       ($hints & $feature::hint_mask) == $feature::hint_mask;
     my @decls;
     my @features;
     my @unfeatures; # bugs?
@@ -1624,7 +1626,6 @@ sub declare_hinthash {
     }
     my @ret;
     if (@features || @unfeatures) {
-       require feature;
        if (!%rev_feature) { %rev_feature = reverse %feature::feature }
     }
     if (@features) {
@@ -1683,13 +1684,9 @@ sub keyword {
     return $name if $name =~ /^CORE::/; # just in case
     if (exists $feature_keywords{$name}) {
        my $hh;
-       my $hints = $self->{hints} & $feature_bundle_mask;
-       if ($hints && $hints != $feature_bundle_mask) {
-           require feature;
-           local $^H = $self->{hints};
-           # Shh! Keep quite about this function.  It is not to be
-           # relied upon.
-           $hh = { map +($feature::feature{$_} => 1), 
@{feature::current_bundle()} };
+       my $hints = $self->{hints} & $feature::hint_mask;
+       if ($hints && $hints != $feature::hint_mask) {
+           $hh = _features_from_bundle($hints);
        }
        elsif ($hints) { $hh = $self->{'hinthash'} }
        return "CORE::$name"
@@ -4546,11 +4543,10 @@ sub re_flags {
     elsif ($self->{hinthash} and
             $self->{hinthash}{reflags_charset}
            || $self->{hinthash}{feature_unicode}
-       or $self->{hints} & $feature_bundle_mask
-         && ($self->{hints} & $feature_bundle_mask)
-              != $feature_bundle_mask
+       or $self->{hints} & $feature::hint_mask
+         && ($self->{hints} & $feature::hint_mask)
+              != $feature::hint_mask
          && do {
-               require feature;
                $self->{hints} & $feature::hint_uni8bit;
             }
   ) {

--
Perl5 Master Repository

Reply via email to