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

[BUGFIX beta] Avoid extra work for Ember.Component#layout. #12299

Merged
merged 1 commit into from
Sep 6, 2015

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Sep 5, 2015

There are a few changes in this PR, listed below:


Prior to this change, layout was a CP that did a few things:

  • get(this, 'layoutName') (and if set this.container.lookup)
  • get(this, 'defaultLayout')

After this change, layout is a simple property that avoids that extra work.


Prior to this change, defaultLayout would actually override a layout that came from the container, this was incorrect (literally the opposite of what we wanted).

This corrects that logic, and ensures that we only attempt to use the layout property if the layout was not found during the container lookup (which properly mimics the behavior in 1.0 - 1.12 where layout was injected into the component if a layout was found in the container).


The basic gist of these changes is less Ember.get's in the normal cases, but full support for existing semantics (aka PAYGO).

if (this.layoutName && this.container) {
let layoutName = get(this, 'layoutName');

set(this, 'layout', this.templateForName(layoutName));
Copy link
Member

Choose a reason for hiding this comment

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

are these observerd, if not we can go straight to native property set, skipping Ember.set

Copy link
Member Author

Choose a reason for hiding this comment

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

Kk, will update (and nothing is observable in init AFAIK).

Copy link
Member Author

Choose a reason for hiding this comment

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

To answer the actual question though: we only check for them once after initial creation, and they are not observed for changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to remove Ember.set and just use property assignment.

@stefanpenner
Copy link
Member

The basic gist of these changes is less Ember.get's in the normal cases, but full support for existing semantics (aka PAYGO).

👍


It would also be nice to see some micro/macro #'s as it aids my mental model (but only do if easy)

@rwjblue
Copy link
Member Author

rwjblue commented Sep 5, 2015

Ya, I will try to run numbers this evening.

Either way I think that less work (that is easier to reason about) should be better for us long term.

---

Prior to this change, `layout` was a CP that did a few things:

* `get(this, 'layoutName')` (and if set `this.container.lookup`)
* `get(this, 'defaultLayout')`

After this change, `layout` is a simple property that avoids that extra
work.

---

Prior to this change, `defaultLayout` would actually override a layout
that came from the container, this was incorrect (literally the opposite
of what we wanted).

This corrects that logic, and ensures that we only attempt to use the
`layout` property if the layout was not found during the container
lookup (which properly mimics the behavior in 1.0 - 1.12 where `layout`
was injected into the component if a layout was found in the container).
@stefanpenner
Copy link
Member

Either way I think that less work (that is easier to reason about) should be better for us long term.

yup

@rwjblue
Copy link
Member Author

rwjblue commented Sep 6, 2015

The average (of 10 runs) with this change is around 2% faster than the prior commit on canary against http://rwjblue.jsbin.com/moquja. I believe it is likely that within the margin of error for this kind of thing though, but seems like win/win either way...

rwjblue added a commit that referenced this pull request Sep 6, 2015
[BUGFIX beta] Avoid extra work for `Ember.Component#layout`.
@rwjblue rwjblue merged commit 57f84a9 into emberjs:master Sep 6, 2015
@rwjblue rwjblue deleted the make-layout-simple-prop branch September 6, 2015 18:34
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.

2 participants