diff options
author | Emil Engler <me@emilengler.com> | 2022-07-30 22:36:55 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2022-08-02 17:10:03 +0200 |
commit | 92179353e5cac4cfb294a1fdcbdbf5d682fc40a1 (patch) | |
tree | 8f5f6881d1f8d23c52d8bc3878adb6f5a147c3e7 /docs/cmdline-opts/gen.pl | |
parent | 209ffd7d8e33d9b07067f216110ccbce92ab873f (diff) | |
download | curl-92179353e5cac4cfb294a1fdcbdbf5d682fc40a1.tar.gz |
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 <torreemanuele6@gmail.com>
See #8299
Fixes #9230
Closes #9232
Diffstat (limited to 'docs/cmdline-opts/gen.pl')
-rwxr-xr-x | docs/cmdline-opts/gen.pl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/cmdline-opts/gen.pl b/docs/cmdline-opts/gen.pl index e69dd996b..cbe454062 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 |