Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Background People at redux-toolkit copy/pasted this utility in there, and [they are not welcoming a PR](reduxjs/redux-toolkit#581) because of that, but the `while` loop in here is completely unnecessary, as the comparison is made on the first `proto` only. ## Improvements * _O(1)_ instead of _O(n)_ * safe fallback for `Object.create(null)` cases * fast lane for `new Class()` derived objects * better performance * smaller code size As this change has zero downsides, unless I am missing some explicit reason to `while` loop instead of never using `getPrototypeOf` more than twice, I hope it'll get in, so that others might copy and paste this new version. Best Regards.
- Loading branch information