Repository navigation
Avoid per-paint allocations for code minings - #4480
Merged
vogella merged 1 commit intoOct 15, 2026
Merged
Conversation
Contributor
vogella
force-pushed
the
lv/codemining-paint-allocations
branch
2 times, most recently
from
October 14, 2026 22:16
63a5df5 to
08ca5fa
Compare
Computing line heights and drawing code minings split labels with a regular expression that String.split cannot fast-path, so a Pattern was compiled on every call, and the next mining's label was split entirely just to read its first line. The inlined annotation drawing strategy also queried the native font data of the widget font and of the annotation font on every draw to decide whether the cached italic font was still valid, and only compared heights, so a font family change kept the stale italic font. The line break pattern is now compiled once, the first line is found with a scan, and hasAtLeastOneResolvedMiningNotEmpty uses plain loops. The drawing strategy remembers which widget font its annotation font was derived from and recreates it whenever the widget font changes. The dispose listener is registered once per widget instead of each time the font is recreated. A label made only of line breaks no longer throws an ArrayIndexOutOfBoundsException and no longer reduces the line count of a multi-mining header. Assisted-by: multiple AI agents and layers of automated tooling 🤖
vogella
force-pushed
the
lv/codemining-paint-allocations
branch
from
October 14, 2026 22:43
08ca5fa to
37da6aa
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The localized changes have regression coverage and no identified blocking issues; tests were not executed.
0 open findings
What changed in this PR
Reduces allocations and native font calls when rendering JFace code minings.
Changes:
- Reuses compiled line-break patterns and scans for the next label’s first line.
- Caches annotation fonts by widget font, with one disposal listener per widget.
- Adds regression tests for font lifecycle and line-break handling.
| File | Description |
|---|---|
| tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/source/inlined/InlinedAnnotationFontTest.java | Tests font replacement, reuse, and disposal. |
| tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/JFaceTextTestSuite.java | Registers the font regression test. |
| tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningLineHeaderAnnotationTest.java | Tests multiline height and line-break-only labels. |
| bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java | Caches derived fonts and simplifies disposal. |
| bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/LineHeaderCodeMining.java | Reuses a compiled pattern during drawing. |
| bundles/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineHeaderAnnotation.java | Reduces height-calculation allocations and handles empty split results. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code minings split their labels with a line break regular expression that String.split cannot fast-path, so a Pattern was compiled on every line height computation and every draw, and the following mining's label was split completely just to read its first line. InlinedAnnotationDrawingStrategy also fetched the native font data of the widget font and the annotation font on every draw to check whether its cached italic font was still valid. The pattern is now compiled once, the first line is found with a scan, and the drawing strategy only compares font data when the widget font instance changes, registering its dispose listener once per widget. This removes several allocations and native calls from the paint path of editors with code minings, and a label consisting only of line breaks now yields an empty first line instead of an ArrayIndexOutOfBoundsException.