@@ -219,6 +219,7 @@ class WordBoundary extends TextBoundary {
219219 };
220220 }
221221
222+ static final RegExp _regExpSpaceSeparatorOrPunctuaion = RegExp (r'[\p{Space_Separator}\p{Punctuation}]' , unicode: true );
222223 bool _skipSpacesAndPunctuations (int offset, bool forward) {
223224 // Use code point since some punctuations are supplementary characters.
224225 // "inner" here refers to the code unit that's before the break in the
@@ -235,7 +236,7 @@ class WordBoundary extends TextBoundary {
235236 final bool hardBreakRulesApply = innerCodePoint == null || outerCodeUnit == null
236237 // WB3a & WB3b: always break before and after newlines.
237238 || _isNewline (innerCodePoint) || _isNewline (outerCodeUnit);
238- return hardBreakRulesApply || ! RegExp ( r'[\p{Space_Separator}\p{Punctuation}]' , unicode : true ) .hasMatch (String .fromCharCode (innerCodePoint));
239+ return hardBreakRulesApply || ! _regExpSpaceSeparatorOrPunctuaion .hasMatch (String .fromCharCode (innerCodePoint));
239240 }
240241
241242 /// Returns a [TextBoundary] suitable for handling keyboard navigation
@@ -332,6 +333,7 @@ class _TextLayout {
332333 };
333334 }
334335
336+ static final RegExp _regExpSpaceSeparators = RegExp (r'\p{Space_Separator}' , unicode: true );
335337 /// The line caret metrics representing the end of text location.
336338 ///
337339 /// This is usually used when the caret is placed at the end of the text
@@ -364,7 +366,7 @@ class _TextLayout {
364366 0x00A0 || // no-break space
365367 0x2007 || // figure space
366368 0x202F => false , // narrow no-break space
367- _ => RegExp ( r'\p{Space_Separator}' , unicode : true ) .hasMatch (lastCodeUnit),
369+ _ => _regExpSpaceSeparators .hasMatch (lastCodeUnit),
368370 };
369371
370372 final double baseline = lineMetrics.baseline;
0 commit comments