badwords: twice as fast

...on my macOS machine, this version uses half the time when
scanning the source.

Closes #20877
This commit is contained in:
Stefan Eissing 2026-03-10 14:48:49 +01:00 committed by Daniel Stenberg
parent 8ec0e1e109
commit c1cea52f12
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -73,15 +73,15 @@ while(<STDIN>) {
# Build a single combined regex for case-insensitive words
my $re_ci;
if(@w) {
my $pat = join('|', map { '\b'.quotemeta($_).'\b' } @w);
$re_ci = qr/($pat)/i;
my $pat = join('|', map { quotemeta($_) } @w);
$re_ci = qr/\b($pat)\b/i;
}
# Build a single combined regex for case-sensitive (exact) words
my $re_cs;
if(@exact) {
my $pat = join('|', map { '\b'.quotemeta($_).'\b' } @exact);
$re_cs = qr/($pat)/;
my $pat = join('|', map { quotemeta($_) } @exact);
$re_cs = qr/\b($pat)\b/;
}
my $errors = 0;