Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 0abf5c5

Browse files
author
Yuncong Zhang
committed
Reuse this._lineBaseLines, this._glyphLines and this._lineHeights
between layouts.
1 parent 99deb24 commit 0abf5c5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Runtime/ui/txt/paragraph.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,18 @@ public void layout(ParagraphConstraints constraints) {
279279
this._codeUnitRuns.Clear();
280280

281281
this._computeLineBreak();
282-
this._glyphLines = new GlyphLine[this._lineRanges.Count];
283-
this._lineBaseLines = new float[this._lineRanges.Count];
284-
this._lineHeights = new float[this._lineRanges.Count];
282+
if (this._glyphLines == null || this._glyphLines.Length < this._lineRanges.Count) {
283+
this._glyphLines = new GlyphLine[this._lineRanges.Count];
284+
}
285+
286+
if (this._lineBaseLines == null || this._lineBaseLines.Length < this._lineRanges.Count) {
287+
this._lineBaseLines = new float[this._lineRanges.Count];
288+
}
289+
290+
if (this._lineHeights == null || this._lineHeights.Length < this._lineRanges.Count) {
291+
this._lineHeights = new float[this._lineRanges.Count];
292+
}
293+
285294
int styleMaxLines = this._paragraphStyle.maxLines ?? int.MaxValue;
286295
this._didExceedMaxLines = this._lineRanges.Count > styleMaxLines;
287296

0 commit comments

Comments
 (0)