Re: [PATCH v4] last-modified: implement faster algorithm
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 3, 2025, 16:44 UTC
- Message-ID
- <xmqq7bw7ukvj.fsf@gitster.g>
- In-Reply-To
- <20251103154726.26592-1-toon@iotcl.com>
Toon Claes <toon@iotcl.com> writes:
Show 5 quoted lines
> Changes in v4: > - Use CALLOC_ARRAY() instead of xcalloc() as identified by Junio using > 'make coccicheck'. > - Small formatting changes. > - Link to v3: https://lore.kernel.org/all/20251023-b4-toon-last-modified-faster-v3-1-40a4ddbbadec@iotcl.com
Sorry, but this came way after I started today's integration cycle, which included merging the fixed-up version to 'next'. I saw some "let's drop {} around the body of if/for with a single statement" changes but each of these single statements was not a simple statement but an if-statement, and personally I feel that it is clearer to enclose them in {} (in other words, once the code is written in that way, it is not worth the patch noise to go and fix them). The only regrettable thing without v4 is the double space between ") {" in the second hunk below X-<, but perhaps it is minor enough to leave it to the next person who touches the vicinity of this code ;-). If you feel strongly about them, please send in an incremental updates, but as I said, I do not think it is necessary.
Thanks.
diff --git a/b0ecbdc540 b/3028abd25e index b0ecbdc540..3028abd25e 100644 --- a/b0ecbdc540 +++ b/3028abd25e @@ -312,10 +312,9 @@ static void process_parent(struct last_modified *lm, bitmap_set(lm->scratch, k); } } - for (size_t i = 0; i < lm->all_paths_nr; i++) { + for (size_t i = 0; i < lm->all_paths_nr; i++) if (bitmap_get(active_c, i) && !bitmap_get(lm->scratch, i)) pass_to_parent(active_c, active_p, i); - } /* * If parent has any active paths, put it on the queue (if not already). @@ -440,12 +439,11 @@ static int last_modified_run(struct last_modified *lm) * Paths that remain active, or not TREESAME with any parent, * were changed by 'c'. */ - if (!bitmap_is_empty(active_c)) { + if (!bitmap_is_empty(active_c)) { data.commit = c; - for (size_t i = 0; i < lm->all_paths_nr; i++) { + for (size_t i = 0; i < lm->all_paths_nr; i++) if (bitmap_get(active_c, i)) mark_path(lm->all_paths[i], NULL, &data); - } } cleanup: