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

Upgrade ASLayoutElementContext to an Object #trivial #344

Merged
merged 2 commits into from
Jun 10, 2017

Conversation

Adlai-Holler
Copy link
Member

This gives us a ton more flexibility for the future.

I'm on vacation so this was a little bit thrown-together, but I'm excited about it! Please give it a thorough review.

The GitHub diff got a little confused, so some lines that didn't change at all appear to have changed, like:

CGFloat const ASLayoutElementParentDimensionUndefined = NAN;
CGSize const ASLayoutElementParentSizeUndefined = {ASLayoutElementParentDimensionUndefined, ASLayoutElementParentDimensionUndefined};

@Adlai-Holler Adlai-Holler changed the title Upgrade ASLayoutElementContext to an Object Upgrade ASLayoutElementContext to an Object #trivial Jun 9, 2017
@Adlai-Holler
Copy link
Member Author

Note: changed the names to push/pop because the semantics around what operations are allowed weren't totally clear once I moved to an object. Also, of course it would be cleaner to have a separate file and maybe a custom initializer, or even a class-method interface to this stuff, but I just wanted to get the basic approach up.

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

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

Nits aside, LGTM!

I agree that we should move to an object if it gives us more flexibility and even needed for other improvements. The number of context objects created shouldn't be big enough to cause noticeable overheads.


pthread_key_t ASLayoutElementContextKey;

static void ASLayoutElementDestructor(void *p) {
if (p != NULL) {
ASDisplayNodeCFailAssert(@"Thread exited without clearing layout element context!");
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Indentation looks off.

// pthread_key_create must be called before the key can be used. This function does that.
void ASLayoutElementContextEnsureKey()
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
pthread_key_create(&ASLayoutElementContextKey, free);
// NOTE: NULL destructorm means that if a thread
Copy link
Member

Choose a reason for hiding this comment

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

What's up?

@Adlai-Holler
Copy link
Member Author

Hey Huy, thanks for the review

@Adlai-Holler Adlai-Holler merged commit c9e4b98 into master Jun 10, 2017
@Adlai-Holler Adlai-Holler deleted the AHLayoutContextObject branch June 10, 2017 05:25
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
* Upgrade ASLayoutElementContext to an object

* Address feedback from Huy
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.

None yet

2 participants