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
update abb patch #3977
base: abb
Are you sure you want to change the base?
update abb patch #3977
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -52,7 +52,10 @@ export function createContext(defaultValue, contextId) { | |||||||
subs.push(c); | ||||||||
let old = c.componentWillUnmount; | ||||||||
c.componentWillUnmount = () => { | ||||||||
subs.splice(subs.indexOf(c), 1); | ||||||||
// Patch: this is a hot path, and taking sub out of the array is much | ||||||||
// faster this way since it's an unordered list. | ||||||||
subs[subs.indexOf(c)] = subs[subs.length - 1]; | ||||||||
subs.pop(); | ||||||||
Comment on lines
+57
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if smaller/faster/slower:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't tested it but I can't see how that'd be any different from having a separate assignment (maybe it'd even get minified to the same thing?) so that's the version I've put into the PR here: #3979 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this suggestion fails if you are removing the last item in the array There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed it does! |
||||||||
if (old) old.call(c); | ||||||||
}; | ||||||||
}; | ||||||||
|
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 also open a PR for against to
master
? Happy to do that as well if you are busy :)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.
Yes for sure! #3979