Stop bubbling priority on equal priority
Unobservable perf fix. Previously we only stopped bubbling if the priority was lower, but we can stop on equal priority, too.
Andrew Clark committed
Jan 7, 2017 at 21:25 UTC
8ad0e0c25b881d0d5015b108732518089a5a93cf
1 file changed
+5
-6
src/renderers/shared/fiber/ReactFiberScheduler.js
+5
-6
@@ -981,8 +981,7 @@ module.exports = function<T, P, I, TI, C, CX, CI>(config : HostConfig<T, P, I, T
981
}
982
}
983
984
- function scheduleRoot(root : FiberRoot) {
985
- const priorityLevel = root.current.pendingWorkPriority;
984
+ function scheduleRoot(root : FiberRoot, priorityLevel : PriorityLevel) {
985
if (priorityLevel === NoWork) {
986
return;
987
}
@@ -999,16 +998,16 @@ module.exports = function<T, P, I, TI, C, CX, CI>(config : HostConfig<T, P, I, T
998
lastScheduledRoot = root;
999
}
1000
}
1001
+ }
1002
1003
+ function scheduleUpdate(fiber : Fiber, priorityLevel : PriorityLevel) {
1004
if (priorityLevel <= nextPriorityLevel) {
1005
// We must reset the current unit of work pointer so that we restart the
1006
// search from the root during the next tick, in case there is now higher
1007
// priority work somewhere earlier than before.
1008
nextUnitOfWork = null;
1009
}
1009
- }
1010
1011
- function scheduleUpdate(fiber : Fiber, priorityLevel : PriorityLevel) {
1011
let node = fiber;
1012
let shouldContinue = true;
1013
while (node && shouldContinue) {
@@ -1017,14 +1016,14 @@ module.exports = function<T, P, I, TI, C, CX, CI>(config : HostConfig<T, P, I, T
1016
// matches) we can exit safely knowing that the rest of the path is correct.
1017
shouldContinue = false;
1018
if (node.pendingWorkPriority === NoWork ||
1020
- node.pendingWorkPriority >= priorityLevel) {
1019
+ node.pendingWorkPriority > priorityLevel) {
1020
// Priority did not match. Update and keep going.
1021
shouldContinue = true;
1022
node.pendingWorkPriority = priorityLevel;
1023
}
1024
if (node.alternate) {
1025
if (node.alternate.pendingWorkPriority === NoWork ||
1027
- node.alternate.pendingWorkPriority >= priorityLevel) {
1026
+ node.alternate.pendingWorkPriority > priorityLevel) {
1027
// Priority did not match. Update and keep going.
1028
shouldContinue = true;
1029
node.alternate.pendingWorkPriority = priorityLevel;