diff --git a/CHANGELOG.md b/CHANGELOG.md index e9752ddbda..731724ca30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ - Renamed `accessibleElements` to `accessibilityElements` and removed the re-definition of the property in ASDisplayView. [Jia Wern Lim](https://github.com/jiawernlim) - Remove double scaling of lineHeightMultiple & paragraphSpacing attributes in ASTextKitFontSizeAdjuster. [Eric Jensen](https://github.com/ejensen) - Add a delegate callback for when the framework has initialized. [Adlai Holler](https://github.com/Adlai-Holler) +- Improve TextNode2 by skipping an unneeded copy during measurement. [Adlai Holler](https://github.com/Adlai-Holler) ## 2.7 - Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877) diff --git a/Source/ASTextNode2.mm b/Source/ASTextNode2.mm index 1cdb77f1ab..813326bddf 100644 --- a/Source/ASTextNode2.mm +++ b/Source/ASTextNode2.mm @@ -232,19 +232,12 @@ static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ]; ASLockScopeSelf(); - ASTextContainer *container; - if (!CGSizeEqualToSize(container.size, constrainedSize)) { - container = [_textContainer copy]; - container.size = constrainedSize; - [container makeImmutable]; - } else { - container = _textContainer; - } + _textContainer.size = constrainedSize; [self _ensureTruncationText]; NSMutableAttributedString *mutableText = [_attributedText mutableCopy]; [self prepareAttributedString:mutableText]; - ASTextLayout *layout = [ASTextNode2 compatibleLayoutWithContainer:container text:mutableText]; + ASTextLayout *layout = [ASTextNode2 compatibleLayoutWithContainer:_textContainer text:mutableText]; return layout.textBoundingSize; }