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

Remove reliance on shared_ptr for ASDisplayNodeLayouts #1131

Merged
merged 7 commits into from
Sep 19, 2018

Conversation

Adlai-Holler
Copy link
Member

No description provided.

@TextureGroup TextureGroup deleted a comment Sep 19, 2018
constrainedSize,
constrainedSize.max,
newLayoutVersion);
var pendingLayout = ASDisplayNodeLayout(newLayout,
Copy link
Contributor

@maicki maicki Sep 19, 2018

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
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.

@@ -43,10 +43,16 @@ struct ASDisplayNodeLayout {
/**
* Returns whether this is valid for a given version
*/
BOOL isValid(NSUInteger version);
BOOL isValid(NSUInteger versionArg) {
Copy link
Contributor

@maicki maicki Sep 19, 2018

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
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
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
Member

Choose a reason for hiding this comment

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

👍

@@ -52,12 +50,12 @@ AS_SUBCLASSING_RESTRICTED
/**
* Previous layout to transition from
*/
@property (nonatomic, readonly) std::shared_ptr<ASDisplayNodeLayout> previousLayout;
@property (nonatomic, readonly) const ASDisplayNodeLayout &previousLayout;
Copy link
Contributor

@maicki maicki Sep 19, 2018

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
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.

Copy link
Member Author

@Adlai-Holler Adlai-Holler Sep 19, 2018

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
Contributor

Choose a reason for hiding this comment

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

Nice

Copy link
Contributor

@maicki maicki left a comment

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
@@ -43,10 +43,16 @@ struct ASDisplayNodeLayout {
/**
* Returns whether this is valid for a given version
*/
BOOL isValid(NSUInteger version);
BOOL isValid(NSUInteger versionArg) {
Copy link
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