From 7e5eb606483ff7356999e24bcdb095a3ecb2e14d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 15 Nov 2022 19:33:40 +0000 Subject: mwrap-perl: use grep and fix regexp There's no need to pay O(n) cost to create a short-lived hash table and the original regexp was obviously wrong :x --- script/mwrap-perl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/script/mwrap-perl b/script/mwrap-perl index 4350fcc..78e71e3 100644 --- a/script/mwrap-perl +++ b/script/mwrap-perl @@ -8,10 +8,9 @@ defined($so) or die 'Mwrap.so not loaded'; my $cur = $ENV{LD_PRELOAD}; if (defined $cur) { my @cur = split(/[: \t]+/, $cur); - my %cur = map { $_ => 1 } @cur; - if (!$cur{$so}) { + if (!grep(/\A\Q$so\E\z/, @cur)) { # drop old redundant versions - my @keep = grep(!m!/Mwrap\.so\$!, @cur); + my @keep = grep(!m!/Mwrap\.so$!, @cur); $ENV{LD_PRELOAD} = join(':', $so, @keep); } } else { -- cgit v1.2.3-24-ge0c7