Skip to content

Avoid unnecessary calls to text layout#34105

Open
mike-spa wants to merge 1 commit into
musescore:mainfrom
mike-spa:avoidUnnecessaryCallsToTextLayout
Open

Avoid unnecessary calls to text layout#34105
mike-spa wants to merge 1 commit into
musescore:mainfrom
mike-spa:avoidUnnecessaryCallsToTextLayout

Conversation

@mike-spa

@mike-spa mike-spa commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This layout call only makes sense if the text is being edited. Otherwise, this function gets called every time we set any font property, including during text creation via initElementStyle.

On the Beethoven 9, the total number of calls to text layout went down from 415.000 to approx 50.000. Most of these unnecessary calls run on empty text so they aren't very expensive, but I still get a 5-6% improvement in the total layout time.

@mike-spa mike-spa requested a review from miiizen July 7, 2026 12:53
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 802ebcef-5586-4013-ab49-184ec0c4ed2a

📥 Commits

Reviewing files that changed from the base of the PR and between 76977e3 and 317ec89.

📒 Files selected for processing (2)
  • src/engraving/dom/textbase.cpp
  • src/engraving/rendering/score/textlayout.cpp

📝 Walkthrough

Walkthrough

Changes

This change modifies TextCursor::changeSelectionFormat in textbase.cpp so that the text relayout call (layoutText1) is executed only when the cursor is in an editing state, rather than unconditionally after applying format changes to selected fragments. Additionally, a TRACEFUNC; statement was added to the beginning of TextLayout::layoutBaseTextBase1 in textlayout.cpp. No public or exported entity declarations were altered.

Sequence Diagram(s)

Not applicable; changes are limited to conditional logic and a trace statement addition without altering component interactions.

Estimated code review effort: 2 (Low-Medium)

Related issues: None specified.

Related PRs: None specified.

Suggested labels: engraving, text-layout

Suggested reviewers: None specified.

Poem:
A rabbit hopped through code so neat,
Found a layout call, made it discreet,
Now it fires only when editing's true,
And traces whisper what functions do,
Small hops, big care—review complete!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required issue reference and nearly all checklist items from the template. Add a Resolves: #NNNN line, a short description, and complete the required checklist items from the template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: reducing unnecessary text layout calls.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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

Warning

Review ran into problems

🔥 Problems

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/muse_framework.git.


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.

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.

1 participant