Add missing insert/emplace methods to SharedMap and SharedHashMap#149
Conversation
|
Warning Review limit reached
Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughSharedMap and SharedHashMap add detach-safe iterator anchoring for shared storage. Their mutation APIs now support const-iterator ranges, hinted insertion, emplacement, try-emplacement, merging, and const-iterator erasure. SharedMap also adds a detaching non-const lookup overload and shared-data comparison short-circuits, while SharedHashMap removes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@framework/global/types/sharedhashmap.h`:
- Around line 170-188: Add a private withDetachedHint helper that performs the
shared use_count check, optionally calls detachAndReanchor, and invokes a
supplied operation with the correct hint or position. Refactor both hinted
insert overloads, emplace_hint, erase(pos), and erase(first, last) to use this
helper while preserving their existing forwarding and return behavior.
- Around line 227-233: Add the missing hint-taking try_emplace overloads
alongside the existing SharedHashMap::try_emplace method: support both
const_iterator hints with const KeyType& and KeyType&& keys, call
ensureDetach(), and forward the hint, key, and constructor arguments to
m_dataPtr->try_emplace while preserving the existing return type and behavior.
In `@framework/global/types/sharedmap.h`:
- Around line 257-263: Extend the shared map’s try_emplace API with both
hint-taking overloads matching std::map: one accepting const_iterator hint and
const KeyType&, and one accepting const_iterator hint and KeyType&&. In each
overload, call ensureDetach() and forward the hint, key, and constructor
arguments to m_dataPtr->try_emplace, preserving the existing hint-less overload.
- Around line 200-218: Consolidate the repeated unique-owned versus
detach-and-reanchor logic in SharedMap’s hint insert overloads, emplace_hint,
erase(pos), and erase(first, last) into a shared helper, matching the existing
SharedHashMap approach. Preserve the use_count() == 1 fast path, re-anchor
iterators only after detaching, and keep each operation’s existing forwarding
and return behavior.
- Around line 342-385: Add targeted unit tests for the new iterator-anchoring
mutation paths in both SharedMap and SharedHashMap, covering empty-map
cbegin()/cend() boundaries, an end() hint, and self-merge behavior. Exercise
detachAndReanchor and detachAndReanchorRange through the relevant public
operations, verifying iterator positions and resulting contents remain correct
after detachment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 27faeabd-9adb-4d52-837c-469ccf8202d6
📒 Files selected for processing (2)
framework/global/types/sharedhashmap.hframework/global/types/sharedmap.h
e9ecc46 to
c1ba705
Compare
c1ba705 to
c38eb46
Compare
No description provided.