This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid unique REGCOMP in dynaloader
authorJ. Nick Koston <nick@cpanel.net>
Wed, 6 Sep 2017 17:18:51 +0000 (12:18 -0500)
committerNicolas R <atoomic@cpan.org>
Fri, 3 Nov 2017 16:32:00 +0000 (11:32 -0500)
Dynaloader has 4 unique regex's that cannot be de-duplicated
by perlcc.  Switch them to index/substr

References: CPANEL-15683

Signed-off-by: Nicolas R <atoomic@cpan.org>
ext/DynaLoader/DynaLoader_pm.PL

index 72e623a..46752b1 100644 (file)
@@ -454,7 +454,7 @@ sub dl_findfile {
 
         # Deal with directories first:
         #  Using a -L prefix is the preferred option (faster and more robust)
-        if (m:^-L:) { s/^-L//; push(@dirs, $_); next; }
+        if (index($_,'-L') == 0) { substr($_,0,2,''); push(@dirs, $_); next; }
 
         #  Otherwise we try to try to spot directories by a heuristic
         #  (this is a more complicated issue than it first appears)
@@ -468,8 +468,8 @@ sub dl_findfile {
 
         #  Only files should get this far...
         my(@names, $name);    # what filenames to look for
-        if (m:-l: ) {          # convert -lname to appropriate library name
-            s/-l//;
+        if (index($_,'-l') == 0) {          # convert -lname to appropriate library name
+            substr($_,0,2,'');
             push(@names,"lib$_.$dl_so");
             push(@names,"lib$_.a");
         } else {                # Umm, a bare name. Try various alternatives: