Skip to content

Commit fdda766

Browse files
Daniel GredlerHarshitha Onkar
authored andcommitted
8356814: LineBreakMeasurer.nextLayout() slower than necessary when no break needed
Reviewed-by: prr, dnguyen, honkar
1 parent 139a05d commit fdda766

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/java.desktop/share/classes/sun/font/ExtendedTextSourceLabel.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,14 @@ protected int v2l(int index) {
875875
}
876876

877877
public TextLineComponent getSubset(int start, int limit, int dir) {
878-
return new ExtendedTextSourceLabel(source.getSubSource(start, limit-start, dir), decorator);
878+
if (start == 0 &&
879+
limit == source.getLength() &&
880+
(dir == source.getBidiLevel() || dir == TextLineComponent.UNCHANGED)) {
881+
return this; // avoid unnecessary object creation and text shaping
882+
} else {
883+
TextSource subSource = source.getSubSource(start, limit-start, dir);
884+
return new ExtendedTextSourceLabel(subSource, decorator);
885+
}
879886
}
880887

881888
public String toString() {

0 commit comments

Comments
 (0)