Skip to content

Commit 8d5be8b

Browse files
avargitster
authored andcommitted
generate-cmdlist.sh: stop sorting category lines
In a preceding commit we changed the print_command_list() loop to use printf's auto-repeat feature. Let's now get rid of get_category_line() entirely by not sorting the categories. This will change the output of the generated code from e.g.: - { "git-apply", N_("Apply a patch to files and/or to the index"), 0 | CAT_complete | CAT_plumbingmanipulators }, To: + { "git-apply", N_("Apply a patch to files and/or to the index"), 0 | CAT_plumbingmanipulators | CAT_complete }, I.e. the categories are no longer sorted, but as they're OR'd together it won't matter for the end result. This speeds up the generate-cmdlist.sh a bit. Comparing HEAD~ (old) and "master" to this code: 'sh generate-cmdlist.sh command-list.txt' ran 1.07 ± 0.33 times faster than 'sh generate-cmdlist.sh.old command-list.txt' 1.15 ± 0.36 times faster than 'sh generate-cmdlist.sh.master command-list.txt' Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 66d55b9 commit 8d5be8b

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

generate-cmdlist.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ command_list () {
99
eval "grep -ve '^#' $exclude_programs" <"$1"
1010
}
1111

12-
get_category_line () {
13-
tr ' ' '\012' |
14-
LC_ALL=C sort -u
15-
}
16-
1712
category_list () {
1813
command_list "$1" |
1914
cut -c 40- |
@@ -67,7 +62,7 @@ print_command_list () {
6762
while read cmd rest
6863
do
6964
printf " { \"$cmd\", $(get_synopsis $cmd), 0"
70-
printf " | CAT_%s" $(echo "$rest" | get_category_line)
65+
printf " | CAT_%s" $rest
7166
echo " },"
7267
done
7368
echo "};"

0 commit comments

Comments
 (0)