Skip to content

Remove reliance on shared_ptr for ASDisplayNodeLayouts - #1131

Merged
nguyenhuy merged 7 commits into
masterfrom
AHRemoveSharedPtr
Sep 19, 2018
Merged

Remove reliance on shared_ptr for ASDisplayNodeLayouts#1131
nguyenhuy merged 7 commits into
masterfrom
AHRemoveSharedPtr

Conversation

@Adlai-Holler

Copy link
Copy Markdown
Member

No description provided.

@TextureGroup TextureGroup deleted a comment Sep 19, 2018
Comment thread Source/ASDisplayNode+Layout.mm Outdated
constrainedSize,
constrainedSize.max,
newLayoutVersion);
var pendingLayout = ASDisplayNodeLayout(newLayout,

@maicki maicki Sep 19, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we change the pendingLayout somewhere to change it to var?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right – in a previous version, setCalculatedLayout mutated the input (to apply the unflattenedLayout thing) but I changed it to copy the input and never committed reverting this to let.

* Returns whether this is valid for a given version
*/
BOOL isValid(NSUInteger version);
BOOL isValid(NSUInteger versionArg) {

@maicki maicki Sep 19, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You think it's worth it to inline?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figure there's no real downside. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep agree

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread Source/Private/ASLayoutTransition.h Outdated
* Previous layout to transition from
*/
@property (nonatomic, readonly) std::shared_ptr<ASDisplayNodeLayout> previousLayout;
@property (nonatomic, readonly) const ASDisplayNodeLayout &previousLayout;

@maicki maicki Sep 19, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure the ref lifes for the full lifetime of the transition?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an ivar on the transition object (it's copied in -init) so it'll live as long as the transition lives.

@Adlai-Holler Adlai-Holler Sep 19, 2018

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a small risk here, which is you read this ref and store it/don't copy it, and then you release the transition while you're holding on to the ref. Our current usage is OK. We could actually change this to be a pointer, and use NS_RETURNS_INNER_POINTER to prevent that … I might try it.

EDIT: Apparently NS_RETURNS_INNER_POINTER works with C++ refs, so I added it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@maicki maicki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

@TextureGroup TextureGroup deleted a comment Sep 19, 2018
* Returns whether this is valid for a given version
*/
BOOL isValid(NSUInteger version);
BOOL isValid(NSUInteger versionArg) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nguyenhuy
nguyenhuy merged commit ceed2d2 into master Sep 19, 2018
@Adlai-Holler
Adlai-Holler deleted the AHRemoveSharedPtr branch September 19, 2018 18:23
mikezucc pushed a commit to mikezucc/Texture that referenced this pull request Oct 2, 2018
…1131)

* Remove reliance on shared_ptr for ASDisplayNodeLayouts

* Fix up

* Fix in yoga

* Back to let

* Returns inner pointer

* Trivial change to kick the CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants