-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add reduce to deopted methods #3820
Conversation
@@ -68,6 +68,9 @@ | |||
// form param named `model`. | |||
Backbone.emulateJSON = false; | |||
|
|||
// A cached regex to detect if the Underscore function contains the `arguments` | |||
// keyword. | |||
var containsArguments = /arguments/; |
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 has to be /\barguments\b/
, no?
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.
Updated.
This is a little gross but so is most of the perf rain dancing we're doing around those parts. |
4c39192
to
2d555ca
Compare
Do we really need to do this though? |
That is need because raw underscore methods behave so. |
Necessarily, no. But'll it catch our screw-ups next time. And it might increase interop with underscore-like libraries that use |
The only library this could refer to is Lo-dash. And afaik he doesn't do anything with |
Not specifically, this could be any handwritten library.
I think lodash is pretty in-line with underscore on the functions Backbone uses. |
Anyone else object? |
@@ -1166,8 +1173,8 @@ | |||
// Underscore methods that we want to implement on the Collection. | |||
// 90% of the core usefulness of Backbone Collections is actually implemented | |||
// right here: | |||
var collectionMethods = { forEach: 3, each: 3, map: 3, collect: 3, reduce: 4, | |||
foldl: 4, inject: 4, reduceRight: 4, foldr: 4, find: 3, detect: 3, filter: 3, | |||
var collectionMethods = { forEach: 3, each: 3, map: 3, collect: 3, reduce: 0, |
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.
Can you separate out these changes from the toString check? These should definitely get merged in.
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.
Done.
All of our currently deoptimized Underscore methods (`pick`, `omit`, `invoke`, `without`, and `difference`) change behavior based on the number of arguments pass to the call. This both adds `reduce` (and friends). Supersedes (and incorporates) jashkenas#3810.
2d555ca
to
7ed8582
Compare
Deopt Underscore methods that change on arguments
All of our currently deoptimized Underscore methods (
pick
,omit
,invoke
,without
, anddifference
) change behavior based on the number of arguments pass to the call. This both addsreduce
(and friends).Supersedes (and incorporates) #3810.