-
-
Notifications
You must be signed in to change notification settings - Fork 15.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
feat(compose): optimize one function case #1701
Conversation
@@ -10,11 +10,16 @@ | |||
*/ | |||
|
|||
export default function compose(...funcs) { | |||
if (funcs.length === 0) { | |||
const { length } = funcs | |||
if (!length) { |
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.
I'd remove this variable extraction. You don't use it below. It's an unnecessary optimization.
Neat. The branching reads a bit better this way IMHO. Can you add a test against the new return? |
Done. |
@@ -12,9 +12,13 @@ | |||
export default function compose(...funcs) { | |||
if (funcs.length === 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.
Should I be using triple = ?
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.
Yep. It's strict equality.
* feat(compose): optimize one function case * style(compose): do not use a variable for funcs.length * test(compose): add test for a single param
No description provided.