This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In makedef.pl, avoid creating %PLATFORMS just for one existence check.
authorNicholas Clark <nick@ccl4.org>
Thu, 28 Jul 2011 13:05:26 +0000 (15:05 +0200)
committerNicholas Clark <nick@ccl4.org>
Mon, 1 Aug 2011 09:53:57 +0000 (11:53 +0200)
A single linear search of @PLATFORMS is simpler and possibly even faster
than building a hash from @PLATFORMS, making one lookup, then discarding the
hash.

Add a block to limit the scope of @PLATFORMS to the code that uses it.

makedef.pl

index 42ca395..0a97ba1 100644 (file)
@@ -54,14 +54,16 @@ while (@ARGV) {
     }
 }
 
-my @PLATFORM = qw(aix win32 wince os2 netware vms);
-my %PLATFORM;
-@PLATFORM{@PLATFORM} = ();
-
-die "PLATFORM undefined, must be one of: @PLATFORM\n"
-    unless defined $ARGS{PLATFORM};
-die "PLATFORM must be one of: @PLATFORM\n"
-    unless exists $PLATFORM{$ARGS{PLATFORM}};
+{
+    my @PLATFORM = qw(aix win32 wince os2 netware vms);
+    my %PLATFORM;
+    @PLATFORM{@PLATFORM} = ();
+
+    die "PLATFORM undefined, must be one of: @PLATFORM\n"
+       unless defined $ARGS{PLATFORM};
+    die "PLATFORM must be one of: @PLATFORM\n"
+       unless exists $PLATFORM{$ARGS{PLATFORM}};
+}
 
 # Is the following guard strictly necessary? Added during refactoring
 # to keep the same behaviour when merging other code into here.