summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2014-01-10 10:33:47 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-01-10 10:33:48 -0800
commit74ca49330a02d66a47be53e91bf3fa8577ddb946 (patch)
tree2181c9b8a26f9a36e59f30129ae25519eab2104f /builtin
parentMerge branch 'vm/octopus-merge-bases-simplify' (diff)
parentbuiltin/help.c: speed up is_git_command() by checking for builtin commands first (diff)
downloadtgif-74ca49330a02d66a47be53e91bf3fa8577ddb946.tar.xz
Merge branch 'ss/builtin-cleanup'
"git help $cmd" unnecessarily enumerated potential command names from the filesystem, even when $cmd is known to be a built-in. Ideas for further optimization, primarily by killing the use of is_in_cmdlist(), were suggested in the discussion, but they can come as follow-ups on top of this series. * ss/builtin-cleanup: builtin/help.c: speed up is_git_command() by checking for builtin commands first builtin/help.c: call load_command_list() only when it is needed git.c: consistently use the term "builtin" instead of "internal command"
Diffstat (limited to 'builtin')
-rw-r--r--builtin/help.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/help.c b/builtin/help.c
index cc17e670ce..1fdefeb686 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -288,6 +288,10 @@ 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);
}
@@ -449,7 +453,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 +461,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);
}