In feature.pm, use a consistent code style in import() and unimport().
authorNicholas Clark <nick@ccl4.org>
Mon, 27 Feb 2012 16:57:54 +0000 (17:57 +0100)
committerNicholas Clark <nick@ccl4.org>
Mon, 19 Mar 2012 09:21:54 +0000 (10:21 +0100)
There were a couple of inconsistencies (shift with/without an explicit @_,
exists with/without(), !@_ vs @_ == 0) which turn out to date back to
before 5.10.0

Also fix an inadvertent use of a single element array slice with a simple
array lookup in current_bundle().

lib/feature.pm
regen/feature.pl

index 58380e9..bc32328 100644 (file)
@@ -302,7 +302,7 @@ bundle is automatically loaded instead.
 sub current_bundle {
     my $bundle_number = $^H & $hint_mask;
     return if $bundle_number == $hint_mask;
-    return $feature_bundle{@hint_bundles[$bundle_number >> $hint_shift]};
+    return $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]};
 }
 
 sub normalise_hints {
@@ -317,15 +317,17 @@ sub normalise_hints {
 
 sub import {
     my $class = shift;
-    if (@_ == 0) {
+
+    if (!@_) {
         croak("No features specified");
     }
+
     if (my $features = current_bundle) {
        # Features are enabled implicitly via bundle hints.
        normalise_hints $features;
     }
     while (@_) {
-        my $name = shift(@_);
+        my $name = shift;
         if (substr($name, 0, 1) eq ":") {
             my $v = substr($name, 1);
             if (!exists $feature_bundle{$v}) {
@@ -358,7 +360,6 @@ sub unimport {
        # Features are enabled implicitly via bundle hints.
        normalise_hints $features;
     }
-
     while (@_) {
         my $name = shift;
         if (substr($name, 0, 1) eq ":") {
@@ -372,7 +373,7 @@ sub unimport {
             unshift @_, @{$feature_bundle{$v}};
             next;
         }
-        if (!exists($feature{$name})) {
+        if (!exists $feature{$name}) {
             unknown_feature($name);
         }
         else {
index aaac912..6d276ce 100755 (executable)
@@ -586,7 +586,7 @@ bundle is automatically loaded instead.
 sub current_bundle {
     my $bundle_number = $^H & $hint_mask;
     return if $bundle_number == $hint_mask;
-    return $feature_bundle{@hint_bundles[$bundle_number >> $hint_shift]};
+    return $feature_bundle{$hint_bundles[$bundle_number >> $hint_shift]};
 }
 
 sub normalise_hints {
@@ -601,15 +601,17 @@ sub normalise_hints {
 
 sub import {
     my $class = shift;
-    if (@_ == 0) {
+
+    if (!@_) {
         croak("No features specified");
     }
+
     if (my $features = current_bundle) {
        # Features are enabled implicitly via bundle hints.
        normalise_hints $features;
     }
     while (@_) {
-        my $name = shift(@_);
+        my $name = shift;
         if (substr($name, 0, 1) eq ":") {
             my $v = substr($name, 1);
             if (!exists $feature_bundle{$v}) {
@@ -642,7 +644,6 @@ sub unimport {
        # Features are enabled implicitly via bundle hints.
        normalise_hints $features;
     }
-
     while (@_) {
         my $name = shift;
         if (substr($name, 0, 1) eq ":") {
@@ -656,7 +657,7 @@ sub unimport {
             unshift @_, @{$feature_bundle{$v}};
             next;
         }
-        if (!exists($feature{$name})) {
+        if (!exists $feature{$name}) {
             unknown_feature($name);
         }
         else {