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

Re: [PATCH] fetch: avoid quadratic loop checking for updated submodules

From
Christian Couder <christian.couder@gmail.com>
Date
Sep 13, 2011, 16:40 UTC
Message-ID
<CAP8UFD3ULs9YLCaaJYGo-_A=KqO4yFy3WHJmO5b_hyRSPzA-Vg@mail.gmail.com>
In-Reply-To
<20110912195652.GA27850@sigill.intra.peff.net>
Hi Peff,
On Mon, Sep 12, 2011 at 9:56 PM, Jeff King <peff@peff.net> wrote:
Show 9 quoted lines
> diff --git a/submodule.c b/submodule.c
> index 7a76edf..00aeb71 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -8,12 +8,17 @@
>  #include "diffcore.h"
>  #include "refs.h"
>  #include "string-list.h"
> +#include "sha1-array.h"
Nice to see you reuse sha1-array!
[...]
Show 5 quoted lines
> +struct argv_array {
> +       const char **argv;
> +       unsigned int argc;
> +       unsigned int alloc;
> +};
But there is already such a struct in bisect.c!
Show 27 quoted lines
> +static void init_argv(struct argv_array *array)
> +{
> +       array->argv = NULL;
> +       array->argc = 0;
> +       array->alloc = 0;
> +}
> +
> +static void push_argv(struct argv_array *array, const char *value)
> +{
> +       ALLOC_GROW(array->argv, array->argc + 2, array->alloc);
> +       array->argv[array->argc++] = xstrdup(value);
> +       array->argv[array->argc] = NULL;
> +}
> +
> +static void clear_argv(struct argv_array *array)
> +{
> +       int i;
> +       for (i = 0; i < array->argc; i++)
> +               free((char **)array->argv[i]);
> +       free(array->argv);
> +       init_argv(array);
> +}
> +
> +static void add_sha1_to_argv(const unsigned char sha1[20], void *data)
> +{
> +       push_argv(data, sha1_to_hex(sha1));
> +}

So it would be nice if you could refactor this and the argv_array functions in bisect.c in the same way you refactored sha1-array.

Thanks, Christian.

Previous: Jeff KingNext: Jeff King
Message 15 of 17 in “fetch: avoid quadratic loop checking for updated submodules”
  1. fetch: avoid quadratic loop checking for updated submodulesJeff King, Sep 12, 2011
  2. Junio C HamanoSep 12, 2011
  3. Jens LehmannSep 13, 2011
  4. Jens LehmannSep 14, 2011
  5. Junio C HamanoSep 12, 2011
  6. Jeff KingSep 12, 2011
  7. Junio C HamanoSep 12, 2011
  8. Jeff KingSep 12, 2011
  9. Junio C HamanoSep 12, 2011
  10. Jens LehmannSep 13, 2011
  11. Jeff KingSep 13, 2011
  12. Marc BranchaudSep 14, 2011
  13. Jens LehmannSep 14, 2011
  14. Jeff KingSep 14, 2011
  15. Christian CouderSep 13, 2011
  16. Jeff KingSep 13, 2011
  17. Junio C HamanoSep 13, 2011

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.