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 do inverse work if inverse is explicitly turned off #4225

Merged
merged 1 commit into from
Mar 9, 2016

Conversation

asakusuma
Copy link
Contributor

If the model explicitly turns off inverse, no work should be done to resolve this inverse.

var inverse = record.type.inverseFor(relationshipMeta.key, store);
let inverseKey;
let inverse = null;
if (!relationshipMeta.options ||
Copy link
Member

Choose a reason for hiding this comment

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

I think this would change the default behavior as it is now, right? If you don't provide an options hash we try to find the inverse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, which is why if !relationshipMeta.options, we take the original path of finding the inverse

Copy link
Contributor

Choose a reason for hiding this comment

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

it is if there is no options it does try

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha. Is false also a documented option for inverse? I haven't seen it before.

Copy link
Contributor

Choose a reason for hiding this comment

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

@asakusuma I think if (options && (options.inverse === false || options.inverse === null)) { return; } maybe more clear

Copy link
Contributor

Choose a reason for hiding this comment

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

or moving it into a function since it will be inlined anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fivetanley good point, I'll remove false. Personally I think false is a better API, but I want to limit the scope of this PR to just the performance improvement.

@krisselden I've updated the PR to use a function as you suggested

krisselden added a commit that referenced this pull request Mar 9, 2016
Don't do inverse work if inverse is explicitly turned off
@krisselden krisselden merged commit 52603f8 into emberjs:master Mar 9, 2016
@stefanpenner
Copy link
Member

Can we regression test this please

@asakusuma
Copy link
Contributor Author

@stefanpenner what exactly do you mean here by regression test?

@krisselden
Copy link
Contributor

@asakusuma add a test that verifies it doesn't do the work.

@krisselden
Copy link
Contributor

On that same note we should add a test that the autodiscovery work is avoided when explicitly defined as well

let inverseKey;
let inverse = null;
if (shouldFindInverse(relationshipMeta)) {
inverse = record.type.inverseFor(relationshipMeta.key, store);
Copy link
Member

Choose a reason for hiding this comment

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

test this code path is take when it should be taken, and not if it should not.

@asakusuma
Copy link
Contributor Author

@krisselden I was under the impression that regression testing is testing that you didn't break previous stuff. Regardless, I can add both of those tests.

@krisselden
Copy link
Contributor

It is that, it is also used to describe testing a bug fix to ensure the fix isn't regressed.

@pangratz
Copy link
Member

@asakusuma I've opened #4236 so we don't lose track adding tests for this. Let me know if you have questions regarding how to add the tests. I'm happy to help. Don't feel obliged, let me know if you don't have time for this. Thanks!

@asakusuma
Copy link
Contributor Author

@pangratz thanks for opening the ticket, I plan on getting to this tomorrow or Friday.

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.

5 participants