mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Only create NSAttributedString if NSTextStorage is nil (#36773)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9952dc2cc3
commit
a675dd7faf
+8
-4
@@ -64,10 +64,14 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsi
|
||||
layoutConstraints:(LayoutConstraints)layoutConstraints
|
||||
textStorage:(NSTextStorage *_Nullable)textStorage
|
||||
{
|
||||
return [self measureNSAttributedString:[self _nsAttributedStringFromAttributedString:attributedString]
|
||||
paragraphAttributes:paragraphAttributes
|
||||
layoutConstraints:layoutConstraints
|
||||
textStorage:textStorage];
|
||||
if (textStorage) {
|
||||
return [self _measureTextStorage:textStorage];
|
||||
} else {
|
||||
return [self measureNSAttributedString:[self _nsAttributedStringFromAttributedString:attributedString]
|
||||
paragraphAttributes:paragraphAttributes
|
||||
layoutConstraints:layoutConstraints
|
||||
textStorage:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)drawAttributedString:(AttributedString)attributedString
|
||||
|
||||
Reference in New Issue
Block a user