-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
split _reduce to _xReduce(for transformers) & _reduce(for reducers) #3248
Conversation
97276fc
to
4b85751
Compare
Notice that this PR doesn't colide with #2767. #2767 is a behavior change. This PR is just a refactor. If we merge this PR and we want to apply the behavior of #2767 we just need to remove the lines: if (typeof list['fantasy-land/reduce'] === 'function') {
return list['fantasy-land/reduce'](fn, acc);
} in and adding in var _baseReduce = _createReduce(_arrayReduce, _methodReduce, _iterableReduce);
export default function _reduce(reducer, acc, list) {
if (typeof list['fantasy-land/reduce'] === 'function') {
return list['fantasy-land/reduce'](fn, acc);
}
return _baseReduce(reducer, acc, list);
} |
Hi! Some benchmarks adding benchs for objects in map.bench.js var obj = {a: 1, b: 2};
...
'map(sq, obj)': function() {
map(sq, obj);
}, Original:
After change:
Using more keys implies less difference in gain of performance:
Original:
After change:
|
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 looks great to me. In the end the code is cleaner, and it's more performant. It's hard to beat that!
🌿
source/ap.js
Outdated
function(acc, f) { return _concat(acc, map(f, applyX)); }, | ||
[], | ||
applyF | ||
) |
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.
Post 1.0
, I would like to do some auto-formatting, using Prettier or something, and from then on simply ignore such things. The trouble, of course, is that auto-formatters are mostly designed around OOP/imperative styles, and those don't always transfer well to FP/declarative code. Still, I would love to simply never have to make such judgement calls.
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.
My bad. I'm gonna revert this formatting part.
internal |
Following the approach about what I said in #3247, I also extracted _arrayReduce and _xArrayReduce to be used in places where function are only working with array lists. In this way, we are not executing additional type checks in cases are not needed.