Skip to content

Add missing insert/emplace methods to SharedMap and SharedHashMap#149

Merged
RomanPudashkin merged 3 commits into
musescore:mainfrom
RomanPudashkin:sharedmap_improvements
Jul 14, 2026
Merged

Add missing insert/emplace methods to SharedMap and SharedHashMap#149
RomanPudashkin merged 3 commits into
musescore:mainfrom
RomanPudashkin:sharedmap_improvements

Conversation

@RomanPudashkin

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@RomanPudashkin, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 85b79bd1-7f8e-4b03-9d23-5e52302baf2f

📥 Commits

Reviewing files that changed from the base of the PR and between e9ecc46 and c38eb46.

📒 Files selected for processing (5)
  • framework/global/tests/CMakeLists.txt
  • framework/global/tests/sharedhashmap_tests.cpp
  • framework/global/tests/sharedmap_tests.cpp
  • framework/global/types/sharedhashmap.h
  • framework/global/types/sharedmap.h
📝 Walkthrough

Walkthrough

SharedMap 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 containsAnyOf.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning No PR description was provided, so the required issue reference, summary, checklist, and testing details are missing. Add a description using the template: issue reference, short motivation, checklist items, and any testing or build notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main insert/emplace updates to SharedMap and SharedHashMap.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between aee9f67 and e9ecc46.

📒 Files selected for processing (2)
  • framework/global/types/sharedhashmap.h
  • framework/global/types/sharedmap.h

Comment thread framework/global/types/sharedhashmap.h
Comment thread framework/global/types/sharedhashmap.h
Comment thread framework/global/types/sharedmap.h
Comment thread framework/global/types/sharedmap.h
Comment thread framework/global/types/sharedmap.h
@RomanPudashkin RomanPudashkin force-pushed the sharedmap_improvements branch from e9ecc46 to c1ba705 Compare July 14, 2026 10:32
@RomanPudashkin RomanPudashkin force-pushed the sharedmap_improvements branch from c1ba705 to c38eb46 Compare July 14, 2026 10:34
@RomanPudashkin RomanPudashkin merged commit 296fde8 into musescore:main Jul 14, 2026
3 checks passed
@RomanPudashkin RomanPudashkin deleted the sharedmap_improvements branch July 14, 2026 10:52
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