From 92179353e5cac4cfb294a1fdcbdbf5d682fc40a1 Mon Sep 17 00:00:00 2001 From: Emil Engler Date: Sat, 30 Jul 2022 22:36:55 +0200 Subject: [PATCH] cmdline-opts/gen.pl: improve performance On some systems, the gen.pl script takes nearly two minutes for the generation of the main-page, which is a completely unacceptable time. The slow performance has two causes: 1. Use of a regex locale operator 2. Useless invokations of loops The commit addresses the first issue by replacing the "\W" wiht [^a-zA-Z0-9_], which is, according to regex101.com, functionally equivalent to the previous operation, except that it is obviously limited to ASCII only, which is fine, as the curl project is English-only anyway. The second issue is being addressed by only running the loop if the line contains a "--" in it. The loop may be completeley removed in the future. Co-authored-by: Emanuele Torre See #8299 Fixes #9230 Closes #9232 --- docs/cmdline-opts/gen.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/cmdline-opts/gen.pl b/docs/cmdline-opts/gen.pl index e69dd996bf..cbe4540625 100755 --- a/docs/cmdline-opts/gen.pl +++ b/docs/cmdline-opts/gen.pl @@ -103,10 +103,10 @@ sub printdesc { print ".fi\n"; # fill-in } # skip lines starting with space (examples) - if($d =~ /^[^ ]/) { + if($d =~ /^[^ ]/ && $d =~ /--/) { for my $k (keys %optlong) { my $l = manpageify($k); - $d =~ s/--$k([^a-z0-9_-])(\W)/$l$1$2/; + $d =~ s/--\Q$k\E([^a-z0-9_-])([^a-zA-Z0-9_])/$l$1$2/; } } # quote "bare" minuses in the output