@@ -188,13 +188,13 @@ public LineRange(int start, int end, int endExcludingWhitespace, int endIncludin
188
188
ParagraphStyle _paragraphStyle ;
189
189
List < LineRange > _lineRanges = new List < LineRange > ( ) ;
190
190
List < float > _lineWidths = new List < float > ( ) ;
191
- List < float > _lineBaseLines = new List < float > ( ) ;
191
+ float [ ] _lineBaseLines ;
192
192
GlyphLine [ ] _glyphLines ;
193
193
float _maxIntrinsicWidth ;
194
194
float _minIntrinsicWidth ;
195
195
float _alphabeticBaseline ;
196
196
float _ideographicBaseline ;
197
- List < float > _lineHeights = new List < float > ( ) ;
197
+ float [ ] _lineHeights ;
198
198
List < PaintRecord > _paintRecords = new List < PaintRecord > ( ) ;
199
199
List < CodeUnitRun > _codeUnitRuns = new List < CodeUnitRun > ( ) ;
200
200
bool _didExceedMaxLines ;
@@ -211,7 +211,7 @@ public LineRange(int start, int end, int endExcludingWhitespace, int endIncludin
211
211
const float kFloatDecorationSpacing = 3.0f ;
212
212
213
213
public float height {
214
- get { return this . _lineHeights . Count == 0 ? 0 : this . _lineHeights . last ( ) ; }
214
+ get { return this . _lineHeights ? . last ( ) ?? 0 ; }
215
215
}
216
216
217
217
public float minIntrinsicWidth {
@@ -269,12 +269,12 @@ public void layout(ParagraphConstraints constraints) {
269
269
this . _needsLayout = false ;
270
270
this . _width = Mathf . Floor ( constraints . width ) ;
271
271
this . _paintRecords . Clear ( ) ;
272
- this . _lineHeights . Clear ( ) ;
273
- this . _lineBaseLines . Clear ( ) ;
274
272
this . _codeUnitRuns . Clear ( ) ;
275
273
276
274
this . _computeLineBreak ( ) ;
277
275
this . _glyphLines = new GlyphLine [ this . _lineRanges . Count ] ;
276
+ this . _lineBaseLines = new float [ this . _lineRanges . Count ] ;
277
+ this . _lineHeights = new float [ this . _lineRanges . Count ] ;
278
278
int styleMaxLines = this . _paragraphStyle . maxLines ?? int . MaxValue ;
279
279
this . _didExceedMaxLines = this . _lineRanges . Count > styleMaxLines ;
280
280
@@ -498,9 +498,9 @@ void updateLineMetrics(FontMetrics metrics, float styleHeight) {
498
498
updateLineMetrics ( metrics , this . _paragraphStyle . lineHeight ?? TextStyle . kDefaultHeight ) ;
499
499
}
500
500
501
- this . _lineHeights . Add ( ( this . _lineHeights . Count == 0 ? 0 : this . _lineHeights . last ( ) )
501
+ this . _lineHeights [ lineNumber ] = ( ( lineNumber == 0 ? 0 : this . _lineHeights [ lineNumber - 1 ] )
502
502
+ Mathf . Round ( maxLineSpacing + maxDescent ) ) ;
503
- this . _lineBaseLines . Add ( this . _lineHeights . last ( ) - maxDescent ) ;
503
+ this . _lineBaseLines [ lineNumber ] = this . _lineHeights [ lineNumber ] - maxDescent ;
504
504
yOffset += Mathf . Round ( maxLineSpacing + preMaxDescent ) ;
505
505
preMaxDescent = maxDescent ;
506
506
float lineXOffset = this . getLineXOffset ( runXOffset ) ;
@@ -670,12 +670,12 @@ public List<TextBox> getRectsForRange(int start, int end) {
670
670
}
671
671
672
672
internal PositionWithAffinity getGlyphPositionAtCoordinate ( float dx , float dy ) {
673
- if ( this . _lineHeights . Count == 0 ) {
673
+ if ( this . _lineHeights == null ) {
674
674
return new PositionWithAffinity ( 0 , TextAffinity . downstream ) ;
675
675
}
676
676
677
677
int yIndex ;
678
- for ( yIndex = 0 ; yIndex < this . _lineHeights . Count - 1 ; ++ yIndex ) {
678
+ for ( yIndex = 0 ; yIndex < this . _lineHeights . Length - 1 ; ++ yIndex ) {
679
679
if ( dy < this . _lineHeights [ yIndex ] ) {
680
680
break ;
681
681
}
@@ -758,7 +758,7 @@ internal Range<int> getWordBoundary(int offset) {
758
758
}
759
759
760
760
public int getLineCount ( ) {
761
- return this . _lineHeights . Count ;
761
+ return this . _lineHeights ? . Length ?? 0 ;
762
762
}
763
763
764
764
void _computeLineBreak ( ) {
0 commit comments