diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-12-22 22:31:59 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-12-24 09:25:19 -0800 |
commit | 83141fdc89d784eac3fe1e46c6b00a63c868774f (patch) | |
tree | 4b1b7c4cd1817d13b8576eccf603c8b788e15540 /lib/feature.pm | |
parent | 6634bb9d0ed117be3584c9446cc6b05b93e3c773 (diff) | |
download | perl-83141fdc89d784eac3fe1e46c6b00a63c868774f.tar.gz |
feature.pm: Move hint normalisation to separate function
PL_hints/$^H can hold feature bundle hints that cause %^H to be
ignored when features are looked up.
When feature->import and ->unimport are invoked, they set bits in $^H
such that %^H is used once more. But they have to modify %^H to con-
tain what the bits in $^H imply.
Up till now, unimport was delegating to import, which meant that more
work was being done than necessary, because import would then detect
the special condition of $^H and repeat (some of) that work.
Diffstat (limited to 'lib/feature.pm')
-rw-r--r-- | lib/feature.pm | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/feature.pm b/lib/feature.pm index 75c6666b55..ff1dd6d44a 100644 --- a/lib/feature.pm +++ b/lib/feature.pm @@ -293,6 +293,16 @@ sub current_bundle { return $feature_bundle{@hint_bundles[$bundle_number >> $hint_shift]}; } +sub normalise_hints { + # Delete any keys that may be left over from last time. + delete @^H{ values(%feature) }; + $^H |= $hint_mask; + for (@{+shift}) { + $^H{$feature{$_}} = 1; + $^H |= $hint_uni8bit if $_ eq 'unicode_strings'; + } +} + sub import { my $class = shift; if (@_ == 0) { @@ -300,12 +310,7 @@ sub import { } if (my $features = current_bundle) { # 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; + normalise_hints $features; } while (@_) { my $name = shift(@_); @@ -332,10 +337,8 @@ sub unimport { my $class = shift; if (my $features = current_bundle) { - # Features are enabled implicitly via bundle hints - # Pass them to import() to put them in a form we can handle. - import(undef, @$features); - $^H |= $hint_mask; + # Features are enabled implicitly via bundle hints. + normalise_hints $features; } # A bare C<no feature> should disable *all* features |