git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] Speed up is_git_command() by checking early for internal commands

From
Christian Couder <christian.couder@gmail.com>
Date
Jan 2, 2014, 08:51 UTC
Message-ID
<CAP8UFD2uq5Q-2F4w2zwH582NTpo9JwiKyHPovQJW+7phbT-b-A@mail.gmail.com>
In-Reply-To
<52C1E09A.8040907@gmail.com>

On Mon, Dec 30, 2013 at 10:07 PM, Sebastian Schuberth <sschuberth@gmail.com> wrote:

Show 20 quoted lines
> Since 2dce956 is_git_command() was 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 internal commands.
>
> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
> ---
>  builtin/help.c |   5 ++
>  git.c          | 242 ++++++++++++++++++++++++++++++---------------------------
>  2 files changed, 132 insertions(+), 115 deletions(-)
>
> diff --git a/builtin/help.c b/builtin/help.c
> index b6fc15e..1f0261e 100644
> --- a/builtin/help.c
> +++ b/builtin/help.c
> @@ -284,10 +284,15 @@ static int git_help_config(const char *var, const char *value, void *cb)
>         return git_default_config(var, value, cb);
>  }
>
> +extern int is_internal_command(const char *s);
> +

Starting the new year in keeping with the fine tradition of asking people who add stuff to clean up what others left behind, I would suggest moving all the code related to internal commands (or maybe all commands) in a new pair of files like "internal-cmds.{c,h}". This way git.c and builtin/help.c could include internal-cmds.h and you wouldn't need such extern declaration.

Happy new year everyone, Christian.

Previous: Sebastian SchuberthNext: Sebastian Schuberth
Message 3 of 4 in “Call load_command_list() only when it is needed”
  1. 1/2 Call load_command_list() only when it is neededSebastian Schuberth, Dec 30, 2013
  2. 2/2 Speed up is_git_command() by checking early for internal commandsSebastian Schuberth, Dec 30, 2013
  3. Christian CouderJan 2, 2014
  4. Sebastian SchuberthJan 2, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.