Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't copy container during ASTextNode2 measure #1115

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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)
Expand Down
11 changes: 2 additions & 9 deletions Source/ASTextNode2.mm
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,12 @@ - (CGSize)calculateSizeThatFits:(CGSize)constrainedSize

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];

[self setNeedsDisplay];

Expand Down