-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Replace arrays and HashMap
with native Map
(with a fallback shim implementation)
#15114
Conversation
Also rename: - `ES6Map[Shim]` --> `NgMap[Shim]` - `$$HashMap` --> `$$Map`
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
I haven't checked how these changes affect performance for various cases. Things that are affected (and the effects are likely to be noticeable):
Things that are affected (and the effects are unlikely to be noticeable):
|
Safari 8 is failing. Buggy implementation of |
var idx = this._idx(key); | ||
if (idx === -1) { | ||
idx = this._lastIndex = this._keys.length; | ||
this._lastKey = key; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't deleting this line break something? Every assignment of lastIndex
must be beside an assignment to lastKey
(and the reverse)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this._lastKey
has been set to key
in the previous call to _idx()
.
We need to re-assign this._lastIndex
here, because the currently set -1
won't be true any more (since we are adding the item), but this._lastKey
stays the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, looks like you're right. That isn't really obvious just looking at this though. Worth putting it back? Or more likely just a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might not be obvious if you are trying to figure out why it is being deleted, but if you look at the code (without knowing it was ever there), I think it is clearer without the comment.
I am fine adding if you still think it helps, though.
Only thing I can see is safari not supporting constructor arguments: https://kangax.github.io/compat-table/es6/#test-Map |
Actually, it could also be a buggy implementation of something unrelated to |
@@ -262,7 +262,7 @@ function publishExternalAPI(angular) { | |||
$window: $WindowProvider, | |||
$$rAF: $$RAFProvider, | |||
$$jqLite: $$jqLiteProvider, | |||
$$HashMap: $$HashMapProvider, | |||
$$Map: $$MapProvider, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need this? If we're going to rename it (breaking change), can we just delete it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a private service, so no breaking change (theoretically). It is used by ngAnimate
(which doesn't have access to the closure).
I couldn't find anything suspicious with Safari 8 + Map. I restarted the job (just in case). UPDATE: Still failing 😞 |
It's Mobile Safari, not the desktop 8.0 one. It says |
I assume they mean OS X 10.10.5, not iOS 10.10.5... Sauce Labs should make it less confusing. |
...but that would mean they're running it on an iOS simulator on OS X and that, in turn, eliminates the bug you linked to as it only manifested itself on real devices. |
I'm just saying it may be a similar randomly appearing bug, not this specific one. Yes, it's a simulator, and it's even not totally clear which version of iOS it simulates. |
f4ba0e3
to
999138a
Compare
The Maybe we need stricter checks for |
@gkalpak The comment only mentions that the |
999138a
to
604d876
Compare
Our specific problem (which I am not exaclty sure what it is) is indeed not mentioned in the comment, but it is a discussion about the incompleteness of the implementation of Map in that version of Safari. So, although we don't need any of the known missing or buggy features, we are affected by some other bug, which results in not being able to retrieve values associated with If anyone is interested, in order to test this, I changed the code to:
There were a bunch of differences (in Here is a Travis log showing (some of) the above (not sure how long Travis keeps old logs around). |
BTW, I updated the commit to use the shim if |
Originally I had a test method before switching to essentially |
Why specifically |
True 😞 There is nothing specific about it, except that it was a way to detect Safari 8 (and probably other browsers with incomplete implementations - but definitely not all). I am fine doing the detection in another, more targeted way, but my main concern remains: |
I'd prefer finding ways of detecting specific bugs, instead of just detecting Safar8-like implementations. But then it might get too ugly, having a test that creates That said, if this allows us to replace |
Looking through the es6-shim checks I don't see anything looking for a bug like this :| |
It'd be interesting to run test262 in this simulator, but what about real iphone and ipads, not simulated? Is Angular actually tested on them? |
HashMap
with native Map
(with a fallback shim implementation)HashMap
with native Map
(with a fallback shim implementation)
I ran the I didn't see any consclusive difference between the three (which probably means that the time spent interacting with
@jbedard, how did you meassure the performance difference for |
f7bf118 is the copy benchmark I normally use |
@jbedard, was that benchmark included into angular/angular.js at some point or are you using it locally? |
That benchmark is not checked in and I just use it locally. At some point I committed it to a local branch to show someone the benchmark I was using, so github does know about the commit but it was never merged. |
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
We have decided to:
|
Closing in favor of #15483. |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Perf improvement (from incorporating #13209) and several refactorings.
What is the current behavior? (You can also link to an open issue here)
Same old, same old.
What is the new behavior (if this is a feature change)?
See #13209. On top of that, the internal
HashMap
/$$HashMap
is replaced with nativeMap
/NgMapShim
, which should improve performance when native implementations are available (i.e. in most cases) and probably slightly decrease speed when falling back to the shim (tbd).Does this PR introduce a breaking change?
No.
Please check if the PR fulfills these requirements
Docs have been added / updated (for bug fixes / features)Other information:
This incorporates and builds on top of #13209.