]> Sergey Matveev's repositories - public-inbox.git/commitdiff
spawn: split() on regexp, not a literal string
authorEric Wong <e@80x24.org>
Mon, 25 Jan 2021 06:41:57 +0000 (22:41 -0800)
committerEric Wong <e@80x24.org>
Tue, 26 Jan 2021 18:51:31 +0000 (18:51 +0000)
It doesn't appear Perl (as of 5.32.x) has any internal
optimization for splitting on a single-byte, so give it
a regexp instead of letting it compile and discard a
new one every single time.

lib/PublicInbox/Spawn.pm

index 376d219096e7d66d3e781f3e3cf1030c2791ed54..86f66605f0a6540180d9bf9f05ff093241511138 100644 (file)
@@ -343,7 +343,7 @@ undef $fdpass;
 sub which ($) {
        my ($file) = @_;
        return $file if index($file, '/') >= 0;
-       foreach my $p (split(':', $ENV{PATH})) {
+       for my $p (split(/:/, $ENV{PATH})) {
                $p .= "/$file";
                return $p if -x $p;
        }