]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
badwords: twice as fast
authorStefan Eissing <stefan@eissing.org>
Tue, 10 Mar 2026 13:48:49 +0000 (14:48 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 10 Mar 2026 15:07:15 +0000 (16:07 +0100)
...on my macOS machine, this version uses half the time when
scanning the source.

Closes #20877

scripts/badwords

index 149150ef23360431e2b579285e357599593cd25f..9c455746361d9d4edf500e41eee18df27b4598f9 100755 (executable)
@@ -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;