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

[PATCH v5 3/9] submodule.c: sort changed_submodule_names before searching it

From
Stefan Beller <sbeller@google.com>
Date
Oct 10, 2018, 21:50 UTC
Message-ID
<20181010215008.233529-4-sbeller@google.com>
In-Reply-To
<20181010215008.233529-1-sbeller@google.com>

We can string_list_insert() to maintain sorted-ness of the list as we find new items, or we can string_list_append() to build an unsorted list and sort it at the end just once.

As we do not rely on the sortedness while building the list, we pick the "append and sort at the end" as it has better worst case execution times.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 submodule.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/submodule.c b/submodule.c
index 0de9e2800a..22c64bd855 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1256,7 +1256,7 @@ static int get_next_submodule(struct child_process *cp,
 		case RECURSE_SUBMODULES_DEFAULT:
 		case RECURSE_SUBMODULES_ON_DEMAND:
 			if (!submodule ||
-			    !unsorted_string_list_lookup(
+			    !string_list_lookup(
 					&changed_submodule_names,
 					submodule->name))
 				continue;
@@ -1350,6 +1350,7 @@ int fetch_populated_submodules(struct repository *r,
 	/* default value, "--submodule-prefix" and its value are added later */
 
 	calculate_changed_submodule_paths();
+	string_list_sort(&changed_submodule_names);
 	run_processes_parallel(max_parallel_jobs,
 			       get_next_submodule,
 			       fetch_start_failure,
-- 
2.19.0
Previous: Stefan BellerNext: Stefan Beller
Message 4 of 10 in “fetch: make sure submodule oids are fetched”
  1. 0/9 fetch: make sure submodule oids are fetchedStefan Beller, Oct 10, 2018
  2. 1/9 sha1-array: provide oid_array_filterStefan Beller, Oct 10, 2018
  3. 2/9 submodule.c: fix indentationStefan Beller, Oct 10, 2018
  4. 3/9 submodule.c: sort changed_submodule_names before searching itStefan Beller, Oct 10, 2018
  5. 4/9 submodule.c: move global changed_submodule_names into fetch submodule structStefan Beller, Oct 10, 2018
  6. 5/9 submodule.c: do not copy around submodule listStefan Beller, Oct 10, 2018
  7. 6/9 repository: repo_submodule_init to take a submodule structStefan Beller, Oct 10, 2018
  8. 7/9 submodule: fetch in submodules git directory instead of in worktreeStefan Beller, Oct 10, 2018
  9. 8/9 fetch: retry fetching submodules if needed objects were not fetchedStefan Beller, Oct 10, 2018
  10. 9/9 builtin/fetch: check for submodule updates for non branch fetchesStefan Beller, Oct 10, 2018

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.