[Repo Assist] perf: replace O(N2) linear scan in dedupe_packages with O(N) HashMap#155
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
Conversation
dedupe_packages previously iterated through the growing deduped vec for every incoming package (iter_mut().find(...)), giving O(N²) complexity. With a HashMap<(id, source_lowercase), index> keyed on the canonical identity, duplicate lookup becomes O(1) amortised. For a typical 'winget list' result with 400 packages this removes ~80k string comparisons; with 500 packages it removes ~125k. Behaviour is identical: - First occurrence of a (id, source) pair wins in insertion order. - If a later entry is strictly better (prefer_package), it replaces the earlier one in-place (maintaining position in the output vec). - source comparison remains case-insensitive: normalised to to_ascii_lowercase() for the HashMap key, matching the previous eq_ignore_ascii_case guard. Two new tests added: - dedupe_packages_source_comparison_is_case_insensitive - dedupe_packages_preserves_insertion_order_of_unique_packages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
What
Replaces the O(N2) linear scan in
dedupe_packageswith an O(N) HashMap-based lookup.Before:
After:
Note
🔒 Integrity filter blocked 1 item
The following item were blocked because they don't meet the GitHub integrity level.
list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: