GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Move guarded callback closer to usage by gaearon · Pull Request #21658 · react/react Conversation
|
|
Comparing: c153679...626cd53 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| function commitBeforeMutationEffectsOnFiber(finishedWork: Fiber) { | ||
| const current = finishedWork.alternate; | ||
| const flags = finishedWork.flags; | ||
| setCurrentDebugFiberInDEV(finishedWork); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think I like the removal of the Snapshot flag check around the switch statement. It seems a little weird to call a method that does not sound (but happens to be ) snapshot-specific (commitBeforeMutationEffectsOnFiber) and then do work without checking in that method.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we add the outer check (so we don't do the guarded callback unnecessarily) and leave the inner check?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I was looking at commitPassiveMountOnFiber which has the check outside. Overall I think there's some tension in this code between having generic naming and avoiding too many guards. I don't know what's a great way to balance but repeating the same check twice in a hot path also seems non-ideal?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agreed. My initial impression was that moving the check outside was not great (b'c less clear) but I see what you're saying too. I don't have strong feelings.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Most fibers do not have a Snapshot flag set. It's a rare case. So with the guard, the most common case is a single check, then you bail out. Without the guard, you have to do at least one check (the switch case) then additional checks for some branches (like class components).
So I would add back the Snapshot check.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Oh there's a check in the outer function. Nvm, didn't see that part.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Diff between two branches (easiest way to review IMO): |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| commitMutationEffectsOnFiber(fiber, root); | ||
| } catch (error) { | ||
| captureCommitPhaseError(fiber, fiber.return, error); | ||
| if (fiber.flags !== NoFlags) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| if (fiber.flags !== NoFlags) { | |
| if ((fiber.flags & MutationMask) !== NoFlags) { |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Just the one nit, LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Oh haha I didn't see #21666. Even better! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.