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 ;-)
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 ;-)
Rebase
I’m no rust expert, so I’ll rely on my LLM here.
- Doesn’t compile. BTreeMap is not imported (repo.rs:98). CI must have been bypassed.
- Second compile error hiding behind the first. entries.values().collect() (repo.rs:100) yields &RepoSummary but the function returns Vec
— needs into_values(). - 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.
- 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.
I can’t seem to find ac600ed8b40d80b456a32edd8d19d3ca9b0a11fb, is it an issue/patch/commit somewhere?