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

Re: [PATCH v2] wt-status: avoid repeated insertion for untracked paths

From
Jeff King <peff@peff.net>
Date
Jul 18, 2026, 07:31 UTC
Message-ID
<20260718073135.GA22588@coredump.intra.peff.net>
In-Reply-To
<20260717144620.259031-1-sahityajb@gmail.com>
On Fri, Jul 17, 2026 at 08:16:20PM +0530, Sahitya Chandra wrote:
Show 9 quoted lines
> wt_status_collect_untracked() copies entries from dir.entries and
> dir.ignored into string_lists using string_list_insert(). That keeps the
> destination lists sorted and deduplicated, but makes the code harder to
> reason about because it rebuilds sorted lists through repeated sorted
> insertion.
> 
> Collect the entries with string_list_append() instead, then sort and
> deduplicate each list once with string_list_sort_u(). This preserves the
> sorted, duplicate-free result while making the collection strategy explicit.

The patch looks good, and I think this explanation is OK-ish. But IMHO it is still worth talking about the quadratic issue, because that's really the motivation here (and what the "harder to reason about" is getting at).

So maybe something like:
  wt_status_collect_untracked() copies entries from dir.entries and
  dir.ignored into string_lists using string_list_insert(). At first
  glance this seems to be quadratic, because we may shift the backing
  array, incurring O(n) work for each insert.
  In practice, though, the entries in the dir struct are already sorted,
  so each we never have to shift the array (and only pay the log-n
  lookup cost for each insertion). But this is subtle and depends on the
  behavior of fill_directory().
  Collect the entries[...etc...]
?
-Peff
Previous: Sahitya ChandraNext: Sahitya Chandra
Message 7 of 10 in “wt-status: avoid quadratic insertion for untracked paths”
  1. wt-status: avoid quadratic insertion for untracked pathsSahitya Chandra, Jul 16, 2026
  2. Patrick SteinhardtJul 17, 2026
  3. Jeff KingJul 17, 2026
  4. Sahitya ChandraJul 17, 2026
  5. Sahitya ChandraJul 17, 2026
  6. wt-status: avoid repeated insertion for untracked pathsSahitya Chandra, Jul 17, 2026
  7. Jeff KingJul 18, 2026
  8. Sahitya ChandraJul 18, 2026
  9. wt-status: avoid repeated insertion for untracked pathsSahitya Chandra, Jul 18, 2026
  10. Jeff KingJul 18, 2026

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.