Skip to content

Commit

Permalink
builtin/help.c: call load_command_list() only when it is needed
Browse files Browse the repository at this point in the history
This avoids list_commands_in_dir() being called when not needed which is
quite slow due to file I/O in order to list matching files in a directory.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Sebastian Schuberth authored and Junio C Hamano committed Jan 6, 2014
1 parent 3f784a4 commit a3c5263
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ static struct cmdnames main_cmds, other_cmds;

static int is_git_command(const char *s)
{
load_command_list("git-", &main_cmds, &other_cmds);
return is_in_cmdlist(&main_cmds, s) ||
is_in_cmdlist(&other_cmds, s);
}
Expand Down Expand Up @@ -449,7 +450,6 @@ int cmd_help(int argc, const char **argv, const char *prefix)
int nongit;
const char *alias;
enum help_format parsed_help_format;
load_command_list("git-", &main_cmds, &other_cmds);

argc = parse_options(argc, argv, prefix, builtin_help_options,
builtin_help_usage, 0);
Expand All @@ -458,6 +458,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
if (show_all) {
git_config(git_help_config, NULL);
printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
load_command_list("git-", &main_cmds, &other_cmds);
list_commands(colopts, &main_cmds, &other_cmds);
}

Expand Down

0 comments on commit a3c5263

Please sign in to comment.