Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Optimize: Collect into sorted collection
Open did:key:z6MkoohH...AjJf opened 1 month ago

I found ac600ed8b40d80b456a32edd8d19d3ca9b0a11fb and thought that this could be optimized by collecting into a sorted collection right away instead of collecting into an unsorted and sorting that afterwards.

This is a proposal, feel free to take or leave however you prefer ;-)

did:key:z6MkoohH...AjJf opened with revision b04e5f67 on base 33b5cd35 +18 -17 1 month ago

I found ac600ed8b40d80b456a32edd8d19d3ca9b0a11fb and thought that this could be optimized by collecting into a sorted collection right away instead of collecting into an unsorted and sorting that afterwards.

This is a proposal, feel free to take or leave however you prefer ;-)

rudolfs pushed revision 2 fc3480c3 on base 052839ac +18 -17 2 days ago

Rebase

rudolfs rejected 2 days ago

I’m no rust expert, so I’ll rely on my LLM here.

  1. Doesn’t compile. BTreeMap is not imported (repo.rs:98). CI must have been bypassed.
  2. Second compile error hiding behind the first. entries.values().collect() (repo.rs:100) yields &RepoSummary but the function returns Vec — needs into_values().
  3. Silent data loss. BTreeMap keyed on name.to_lowercase() drops repos whose lowercased names collide. Repo names aren’t unique across RIDs in Radicle, so this is a real regression vs. the old Vec + sort.
  4. Not an optimization. Per-node heap allocations + tree rebalancing + an extra walk to rebuild the Vec is strictly worse than one Vec + one sort_by_key.

There’s not much to optimize for this function. n is small (tens to low thousands of repos) and storage.repositories()? does the disk I/O that dominates everything else.

rudolfs commented on revision 1 2 days ago

I can’t seem to find ac600ed8b40d80b456a32edd8d19d3ca9b0a11fb, is it an issue/patch/commit somewhere?