Profile information from my application:
- 4.3% + 1.5% of time is spent in
com.sun.javafx.collections.VetoableListDecorator.add, which is called from org.fxmisc.richtext.ParagraphText.<init>.
The following objects are instantiated for each paragraph, regardless of whether they get used:
private final Path caretShape = new Path();
private final Path selectionShape = new Path();
private final List<Path> backgroundShapes = new ArrayList<>();
private final List<Path> underlineShapes = new ArrayList<>();
The selection shape, in particular, probably doesn't need to have an object assigned until needed. This implies that the following lines in the constructor might also be suitable for lazy initialization:
// selection highlight
selectionShape.setManaged(false);
selectionShape.setFill(Color.DODGERBLUE);
selectionShape.setStrokeWidth(0);
selectionShape.layoutXProperty().bind(leftInset);
selectionShape.layoutYProperty().bind(topInset);
getChildren().add(selectionShape);
Another minor hot-spot in the application came from lines 113 to 125 of TextExt. If it is possible to cache the superclass' CSS meta data, rather than create a new list each time, it might offer a small performance boost.
Profile information from my application:
com.sun.javafx.collections.VetoableListDecorator.add, which is called fromorg.fxmisc.richtext.ParagraphText.<init>.ParagraphText
The following objects are instantiated for each paragraph, regardless of whether they get used:
The selection shape, in particular, probably doesn't need to have an object assigned until needed. This implies that the following lines in the constructor might also be suitable for lazy initialization:
TextExt
Another minor hot-spot in the application came from lines 113 to 125 of TextExt. If it is possible to cache the superclass' CSS meta data, rather than create a new list each time, it might offer a small performance boost.