perf: linear-time key lookups in workspace joins#2710
Conversation
Replace the O(n) list membership and index searches with an O(1) dict lookup built once from the primary items. The dict is intentionally not updated when secondary items are appended, preserving the existing behaviour for duplicate-keyed secondary items. Also removes the stale "this will be slow" comment. Assisted-by: ClaudeCode:claude-sonnet-4.6
|
Warning Review limit reached
More reviews will be available in 29 minutes and 58 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2710 +/- ##
==========================================
- Coverage 98.28% 96.47% -1.82%
==========================================
Files 65 65
Lines 4305 4306 +1
Branches 465 465
==========================================
- Hits 4231 4154 -77
- Misses 46 119 +73
- Partials 28 33 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🤖 AI text below 🤖
Part of the code review in #2706.
Summary
keys = [item[key] for item in joined_items]+keys.index(...)with akey_to_indexdict built once from the primary items, giving O(1) membership tests and index lookups instead of O(n) per secondary item.secondary_item not in primary_itemscomparison in theouterjoin branch is left as-is (different semantics — full equality check, not keyed).# NB: this will be slow for large numbers of itemscomment since it no longer applies to the keyed lookups.Test plan
pytest tests/test_workspace.py -q— 253 tests, all passing, no warningsprek -a --quiet— all pre-commit hooks pass with no changes🤖 Generated with Claude Code