Skip to content

Commit 6d6b6a8

Browse files
sammy-SCkelset
authored andcommitted
Only create NSAttributedString if NSTextStorage is nil (facebook#36773)
Summary: Pull Request resolved: facebook#36773 Changelog: [internal] Do not construct `NSAttributedString` if `NSTextStorage` exists. Creating `NSAttributedString` is expensive and it isn't needed to measure text if `NSTextStorage` `exists` Reviewed By: cipolleschi Differential Revision: D44620292 fbshipit-source-id: 0827c514e40fcbd9626d2b7d7b6d28a3332d9aa1
1 parent 614e410 commit 6d6b6a8

File tree

1 file changed

+8
-4
lines changed
  • packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager

1 file changed

+8
-4
lines changed

packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ - (TextMeasurement)measureAttributedString:(AttributedString)attributedString
6464
layoutConstraints:(LayoutConstraints)layoutConstraints
6565
textStorage:(NSTextStorage *_Nullable)textStorage
6666
{
67-
return [self measureNSAttributedString:[self _nsAttributedStringFromAttributedString:attributedString]
68-
paragraphAttributes:paragraphAttributes
69-
layoutConstraints:layoutConstraints
70-
textStorage:textStorage];
67+
if (textStorage) {
68+
return [self _measureTextStorage:textStorage];
69+
} else {
70+
return [self measureNSAttributedString:[self _nsAttributedStringFromAttributedString:attributedString]
71+
paragraphAttributes:paragraphAttributes
72+
layoutConstraints:layoutConstraints
73+
textStorage:nil];
74+
}
7175
}
7276

7377
- (void)drawAttributedString:(AttributedString)attributedString

0 commit comments

Comments
 (0)