@samitouri / QOS-React-2 / commits / b4178af81b

clean up nextEffect pointers (#16115)

Paul Shen committed Jul 17, 2019 at 17:21 UTC b4178af81b02dfa0e898670ce564c4649fd8947f
1 file changed +14 -1
packages/react-reconciler/src/ReactFiberWorkLoop.js
+14 -1
@@ -1712,6 +1712,16 @@ function commitRootImpl(root) {
1712 rootDoesHavePassiveEffects = false;
1713 rootWithPendingPassiveEffects = root;
1714 pendingPassiveEffectsExpirationTime = expirationTime;
1715 + } else {
1716 + // We are done with the effect chain at this point so let's clear the
1717 + // nextEffect pointers to assist with GC. If we have passive effects, we'll
1718 + // clear this in flushPassiveEffects.
1719 + nextEffect = firstEffect;
1720 + while (nextEffect !== null) {
1721 + const nextNextEffect = nextEffect.nextEffect;
1722 + nextEffect.nextEffect = null;
1723 + nextEffect = nextNextEffect;
1724 + }
1725 }
1726
1727 // Check if there's remaining work on this root
@@ -1947,7 +1957,10 @@ export function flushPassiveEffects() {
1957 captureCommitPhaseError(effect, error);
1958 }
1959 }
1950 - effect = effect.nextEffect;
1960 + const nextNextEffect = effect.nextEffect;
1961 + // Remove nextEffect pointer to assist GC
1962 + effect.nextEffect = null;
1963 + effect = nextNextEffect;
1964 }
1965
1966 if (enableSchedulerTracing) {