Skip to content

perf(mq-check): replace Vec with FxHashMap for deferred_overloads#1393

Merged
harehare merged 2 commits intofix/mq-check-overloadfrom
copilot/sub-pr-1391
Mar 5, 2026
Merged

perf(mq-check): replace Vec with FxHashMap for deferred_overloads#1393
harehare merged 2 commits intofix/mq-check-overloadfrom
copilot/sub-pr-1391

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 5, 2026

add_deferred_overload was doing a linear scan on every insert to find and replace an existing entry for the same SymbolId, making the collection phase O(n²) for programs with many deferred overloads.

Changes

  • InferenceContext::deferred_overloads: Vec<DeferredOverload>FxHashMap<SymbolId, DeferredOverload>
  • add_deferred_overload: replaced iter_mut().find(...) + conditional push with a single map.insert(symbol_id, deferred) — O(1) for both new entries and replacements
  • take_deferred_overloads: drains the map into a Vec<DeferredOverload>, preserving the return type so all callers in lib.rs are unaffected

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Address feedback from review on deferred overload replacement fix perf(mq-check): replace Vec with FxHashMap for deferred_overloads Mar 5, 2026
@harehare harehare marked this pull request as ready for review March 5, 2026 13:20
@harehare harehare merged commit dc5c59d into fix/mq-check-overload Mar 5, 2026
@harehare harehare deleted the copilot/sub-pr-1391 branch March 5, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants