git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Call load_command_list() only when it is needed
@ 2013-12-30 21:05 Sebastian Schuberth
  2013-12-30 21:07 ` [PATCH 2/2] Speed up is_git_command() by checking early for internal commands Sebastian Schuberth
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Schuberth @ 2013-12-30 21:05 UTC (permalink / raw)
  To: git; +Cc: chriscool

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>
---
 builtin/help.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/builtin/help.c b/builtin/help.c
index cc17e67..b6fc15e 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);
 	}
 
-- 
1.8.4.msysgit.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-02 12:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-30 21:05 [PATCH 1/2] Call load_command_list() only when it is needed Sebastian Schuberth
2013-12-30 21:07 ` [PATCH 2/2] Speed up is_git_command() by checking early for internal commands Sebastian Schuberth
2014-01-02  8:51   ` Christian Couder
2014-01-02 12:46     ` Sebastian Schuberth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).