Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 will fail with
Object.create(null)
, which is a perfectly fine plain object.See #2599 for some edge case discussions.
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.
great comment, thank you!
there is a complex logic with loop, and make things simpler is profit itself
think we should do this if can iterate less without troubles
case with no proto is fixed in new commit, also added tests for it
speed results almost 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.
I'm just running this in Firefox, and your solution is significantly slower in many cases and only noticeably faster in the
new Date
case.There is a way to speed up the existing logic by skipping one
Object.getPrototype
call withwhich seems to be a much safer change that is not potentially breaking.
Please let's step back for a while: Why are you optimizing this? Does this make anything any slower in any real life application you have?
Any change we introduce here might break edge cases we don't know about. Without having a really good reason to, I don't think that code like this should ever be touched.
And a microoptimization is rarely a good reason - so I'm asking again: do you see real impact on this in a real-life application? What is a use case where this makes a difference?
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.
Please stop adding more optimizations.
We will not accept this pull request unless you give us an incredibly good reason to introduce potentially-breaking code to millions of installations.
I have asked multiple times why you are doing this PR in the first place.
Please start talking.
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.
You right, in firefox i can see slower results too.
Can speed up it with replacing first line of code. Results are only positive.
There is no question of UX improvements. Surplus iterations spend energy in real world. It fraught with some surplus damage to ecology. Redux has 7.5 millions of weekly downloads. It is not catastrophic scope for little loop, but it is and can be not.
You shown an hidden error in my code, thank you. But javascript is not endless. Function is simple. We can fix it instantly in case of error.
With excluding cycle code will pretty easer, people will not spend their time on puzzling it.
Totally this pr: