submodule.c: sort changed_submodule_names before searching it
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Nov 28, 2018 at 16:27 UTC
08a297bd4996480f0b03830058f413bb24f0d37c
1 file changed
+2
-1
submodule.c
+2
-1
@@ -1283,7 +1283,7 @@ static int get_next_submodule(struct child_process *cp,
1283
case RECURSE_SUBMODULES_DEFAULT:
1284
case RECURSE_SUBMODULES_ON_DEMAND:
1285
if (!submodule ||
1286
- !unsorted_string_list_lookup(
1286
+ !string_list_lookup(
1287
&changed_submodule_names,
1288
submodule->name))
1289
continue;
@@ -1377,6 +1377,7 @@ int fetch_populated_submodules(struct repository *r,
1377
/* default value, "--submodule-prefix" and its value are added later */
1378
1379
calculate_changed_submodule_paths(r);
1380
+ string_list_sort(&changed_submodule_names);
1381
run_processes_parallel(max_parallel_jobs,
1382
get_next_submodule,
1383
fetch_start_failure,