]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
bash_aliases: Optimize man_section()
authorAlejandro Colomar <alx@kernel.org>
Fri, 7 Apr 2023 20:58:30 +0000 (22:58 +0200)
committerAlejandro Colomar <alx@kernel.org>
Fri, 7 Apr 2023 22:09:47 +0000 (00:09 +0200)
mandoc(1) renders pages much faster than groff(1), which is itself much
faster than using man(1).  This might seem irrelevant for a single page,
but this function is called in a loop in man_lsfunc() and man_lsvar(),
where this brings times down considerably.  For comparison,
`time man_lsfunc man*` took around 55 s (on my system) before this
change.  With groff(1), it would take around 14 s, and with mandoc(1)
(this patch), it takes 4 s.

Cc: Ingo Schwarze <schwarze@openbsd.org>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: Gavin Smith <gavinsmith0123@gmail.com>
Cc: Dirk Gouders <dirk@gouders.net>
Cc: Colin Watson <cjwatson@debian.org>
Cc: Eli Zaretskii <eliz@gnu.org>
Cc: Larry McVoy <lm@mcvoy.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
scripts/bash_aliases

index 9f7d10409361c14eda4a5a13c9431a17397b3be4..5c0458402e8f4f561a67be860df1590f28ed2ad1 100644 (file)
@@ -65,7 +65,8 @@ man_section()
                                -e "/^\.SH $s/p" \
                                -e "/^\.SH $s/,/^\.SH/{/^\.SH/!p}";
                 done;) \
-               |man -P cat -l - 2>/dev/null;
+               |mandoc -Tutf8 2>/dev/null \
+               |col -pbx;
        done;
 }