From a3c5263438f7c0ff7dd4d0d8ea86ed7a84a32d18 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Thu, 2 Jan 2014 17:16:30 +0100 Subject: builtin/help.c: call load_command_list() only when it is needed 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 Signed-off-by: Junio C Hamano --- builtin/help.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'builtin') diff --git a/builtin/help.c b/builtin/help.c index cc17e670c..b6fc15e5b 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -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); } @@ -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); @@ -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); } -- cgit v1.2.1 From c6127fa3e25551e969d775b0332d37dc84db1969 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Thu, 2 Jan 2014 17:17:11 +0100 Subject: builtin/help.c: speed up is_git_command() by checking for builtin commands first Since 2dce956 is_git_command() is a bit slow as it does file I/O in the call to list_commands_in_dir(). Avoid the file I/O by adding an early check for the builtin commands. Signed-off-by: Sebastian Schuberth Signed-off-by: Junio C Hamano --- builtin/help.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'builtin') diff --git a/builtin/help.c b/builtin/help.c index b6fc15e5b..1fdefeb68 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -288,6 +288,9 @@ static struct cmdnames main_cmds, other_cmds; static int is_git_command(const char *s) { + if (is_builtin(s)) + return 1; + load_command_list("git-", &main_cmds, &other_cmds); return is_in_cmdlist(&main_cmds, s) || is_in_cmdlist(&other_cmds, s); -- cgit v1.2.1