Skip to content

Commit

Permalink
Centralize the pointer updates in the scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Sep 28, 2017
1 parent eaf1ae0 commit 3afc7b4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
4 changes: 0 additions & 4 deletions src/renderers/shared/fiber/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
return bailoutOnLowPriority(current, workInProgress);
}

if (__DEV__) {
ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
}

switch (workInProgress.tag) {
case IndeterminateComponent:
return mountIndeterminateComponent(
Expand Down
8 changes: 0 additions & 8 deletions src/renderers/shared/fiber/ReactFiberCompleteWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ var {
var {Placement, Ref, Update} = ReactTypeOfSideEffect;
var {OffscreenPriority} = ReactPriorityLevel;

if (__DEV__) {
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
}

var invariant = require('fbjs/lib/invariant');

module.exports = function<T, P, I, TI, PI, C, CX, PL>(
Expand Down Expand Up @@ -187,10 +183,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
workInProgress: Fiber,
renderPriority: PriorityLevel,
): Fiber | null {
if (__DEV__) {
ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
}

// Get the latest props.
let newProps = workInProgress.pendingProps;
if (newProps === null) {
Expand Down
20 changes: 14 additions & 6 deletions src/renderers/shared/fiber/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,13 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
// means that we don't need an additional field on the work in
// progress.
const current = workInProgress.alternate;
if (__DEV__) {
ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
}
const next = completeWork(current, workInProgress, nextPriorityLevel);
if (__DEV__) {
ReactDebugCurrentFiber.resetCurrentFiber();
}

const returnFiber = workInProgress.return;
const siblingFiber = workInProgress.sibling;
Expand Down Expand Up @@ -706,8 +712,12 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
// See if beginning this work spawns more work.
if (__DEV__) {
startWorkTimer(workInProgress);
ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
}
let next = beginWork(current, workInProgress, nextPriorityLevel);
if (__DEV__) {
ReactDebugCurrentFiber.resetCurrentFiber();
}
if (__DEV__ && ReactFiberInstrumentation.debugTool) {
ReactFiberInstrumentation.debugTool.onBeginWork(workInProgress);
}
Expand All @@ -718,9 +728,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
}

ReactCurrentOwner.current = null;
if (__DEV__) {
ReactDebugCurrentFiber.resetCurrentFiber();
}

return next;
}
Expand All @@ -735,8 +742,12 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
// See if beginning this work spawns more work.
if (__DEV__) {
startWorkTimer(workInProgress);
ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
}
let next = beginFailedWork(current, workInProgress, nextPriorityLevel);
if (__DEV__) {
ReactDebugCurrentFiber.resetCurrentFiber();
}
if (__DEV__ && ReactFiberInstrumentation.debugTool) {
ReactFiberInstrumentation.debugTool.onBeginWork(workInProgress);
}
Expand All @@ -747,9 +758,6 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
}

ReactCurrentOwner.current = null;
if (__DEV__) {
ReactDebugCurrentFiber.resetCurrentFiber();
}

return next;
}
Expand Down

0 comments on commit 3afc7b4

Please sign in to comment.