JDK-8355986 : Optimize the creation/updating of RichParagraph in CodeArea
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: jfx24
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2025-04-30
  • Updated: 2025-09-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
Currently, CodeArea updates RichParagraph using the SyntaxDecorator#createRichParagraph(CodeTextModel ctm, int i) method even when it's completely unnecessary.

For example, consider a CodeArea with 1000 paragraphs and a visible area of 10 paragraphs. If the user modifies just one visible paragraph (e.g., by adding an 'A' character), CodeArea will recreate (via the createRichParagraph method) approximately 120-220 paragraphs depending on the modified paragraph's position. This seems excessive to me. After all, we're talking about a model - why create new paragraph instances every time when they haven't been modified?

Therefore, I propose that the createRichParagraph method should only be called when absolutely necessary, such as:

1. For initial paragraph creation
2. For creating a new version of a paragraph when it has been modified by the user
3. When code-generated events indicate paragraph changes, style modifications, etc.



Comments
More suggestions from Jurgen Doll: https://mail.openjdk.org/pipermail/openjfx-discuss/2025-September/000272.html
02-09-2025

Good idea. Some optimization is indeed possible - the current implementation eagerly drops the cache on every change, regardless of whether it's warranted or not.
30-04-2025