-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
applyTransforms hasOwnProp is mega slow #2289
Comments
@stefanpenner This is the same as #2213 I think @fivetanley said that partial normalisation will not be supported out of the box anymore, in this case, we can simply remove all those checks. |
@sly7-7 I think this check is more for stuff like |
@fivetanley doubtful eachAttribute would have to yield something invalid |
@stefanpenner would checking to see |
@bmac yes |
I took a stab at fixing this with #4281. The suggested fix to use So I ended up using |
I discussed this with @stefanpenner and @bmac at EmberConf and Stef suggested that, since the current fix might actually not improve performance, I look at the tests that fail when I applied the simple property lookup solution (suggested above by Brendan). More precisely, we don't need to test if |
@stefanpenner @bmac How should I go about this? Should this issue be reopened and then another PR submitted with the solution suggested in my previous comment? |
@balinterdi feel free to open another PR with the solution from your previous comment. |
@stefanpenner @bmac I started removing the test cases that assert that setting a DS.attr to undefined results in the attribute's value to be null (for string and number attrs) or false (for Boolean) values but it occurred to me that attributes cannot only be set from server responses but also directly, in user code (e.g The tests even account for this as they have both I can't think of a good reason to allow ED users to set their attribute values to undefined when they can set it to null to indicate a missing value but I want to hear your take on this before I embark on this. If you agree with this, the tests that should be removed are the ones where the attr is set to undefined, be it from the server or directly. Tests where the attr is set to null (both directly and from the server, as null is a valid JSON value) should remain intact. |
if they explicit set to undefined, we could detect and go down the sentinel internal value path i talked about. (im not totally sure that would work in this case, but maybe worth exploring) |
I believe the relevant code that we care about in this issue https://github.com/balinterdi/data/blob/c2839ac545b25c22c8dc51387761874d9ecdc781/addon/serializers/json.js#L196 only runs when "deserializing" data provided by the server. Ember Data takes another code path when it serializes user provided data (e.g. |
some good news: https://chromium.googlesource.com/v8/v8.git/+/bc8f9a78f05c7a9dce0a112835d797d8082749eb (so the future may be faster, but we should still do this). |
@bmac I checked and @stefanpenner I don't see the value in allowing users to set attribute values (of type string, number and boolean) to |
Yes, |
Thought about this some more. The test cases that now fail correspond to the use case where So I think it's fair to remove these test cases as they assert unrealistic situations and just go with If you don't object, I'll create the corresponding PR. |
Sounds good to me @balinterdi. |
Pull request submitted at #4311 |
data/packages/ember-data/lib/serializers/json_serializer.js
Line 112 in e1ca37a
we should try and merely have sensible behaviour for the if the key is undefined and avoid this costly step until browsers make it fast.
The text was updated successfully, but these errors were encountered: