Skip to content

Commit

Permalink
Delete batchedEventUpdates (#21774)
Browse files Browse the repository at this point in the history
No longer used anywhere.
  • Loading branch information
acdlite committed Jun 30, 2021
1 parent ae5afb3 commit c96761c
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 98 deletions.
2 changes: 0 additions & 2 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {createRoot, hydrateRoot, isValidContainer} from './ReactDOMRoot';
import {createEventHandle} from './ReactDOMEventHandle';

import {
batchedEventUpdates,
batchedUpdates,
discreteUpdates,
flushDiscreteUpdates,
Expand Down Expand Up @@ -102,7 +101,6 @@ setBatchingImplementation(
batchedUpdates,
discreteUpdates,
flushDiscreteUpdates,
batchedEventUpdates,
);

function createPortal(
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/events/DOMPluginEventSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
getEventHandlerListeners,
} from '../client/ReactDOMComponentTree';
import {COMMENT_NODE} from '../shared/HTMLNodeType';
import {batchedEventUpdates} from './ReactDOMUpdateBatching';
import {batchedUpdates} from './ReactDOMUpdateBatching';
import getListener from './getListener';
import {passiveBrowserEventsSupported} from './checkPassiveEvents';

Expand Down Expand Up @@ -630,7 +630,7 @@ export function dispatchEventForPluginEventSystem(
}
}

batchedEventUpdates(() =>
batchedUpdates(() =>
dispatchEventsForPlugins(
domEventName,
eventSystemFlags,
Expand Down
9 changes: 0 additions & 9 deletions packages/react-dom/src/events/ReactDOMUpdateBatching.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ let discreteUpdatesImpl = function(fn, a, b, c, d) {
return fn(a, b, c, d);
};
let flushDiscreteUpdatesImpl = function() {};
// TODO: Remove references to batchedEventUpdates
// let batchedEventUpdatesImpl = batchedUpdatesImpl;

let isInsideEventHandler = false;
// let isBatchingEventUpdates = false;

function finishEventHandler() {
// Here we wait until all updates have propagated, which is important
Expand Down Expand Up @@ -62,9 +59,6 @@ export function batchedUpdates(fn, a, b) {
}
}

// TODO: Remove references to batchedEventUpdates
export const batchedEventUpdates = batchedUpdates;

// TODO: Replace with flushSync
export function discreteUpdates(fn, a, b, c, d) {
return discreteUpdatesImpl(fn, a, b, c, d);
Expand All @@ -74,11 +68,8 @@ export function setBatchingImplementation(
_batchedUpdatesImpl,
_discreteUpdatesImpl,
_flushDiscreteUpdatesImpl,
_batchedEventUpdatesImpl,
) {
batchedUpdatesImpl = _batchedUpdatesImpl;
discreteUpdatesImpl = _discreteUpdatesImpl;
flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl;
// TODO: Remove references to batchedEventUpdates
// batchedEventUpdatesImpl = _batchedEventUpdatesImpl;
}
7 changes: 1 addition & 6 deletions packages/react-native-renderer/src/ReactFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import './ReactFabricInjection';
import {
findHostInstance,
findHostInstanceWithWarning,
batchedEventUpdates,
batchedUpdates as batchedUpdatesImpl,
discreteUpdates,
createContainer,
Expand Down Expand Up @@ -246,11 +245,7 @@ function createPortal(
return createPortalImpl(children, containerTag, null, key);
}

setBatchingImplementation(
batchedUpdatesImpl,
discreteUpdates,
batchedEventUpdates,
);
setBatchingImplementation(batchedUpdatesImpl, discreteUpdates);

const roots = new Map();

Expand Down
7 changes: 1 addition & 6 deletions packages/react-native-renderer/src/ReactNativeRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
findHostInstance,
findHostInstanceWithWarning,
batchedUpdates as batchedUpdatesImpl,
batchedEventUpdates,
discreteUpdates,
createContainer,
updateContainer,
Expand Down Expand Up @@ -237,11 +236,7 @@ function createPortal(
return createPortalImpl(children, containerTag, null, key);
}

setBatchingImplementation(
batchedUpdatesImpl,
discreteUpdates,
batchedEventUpdates,
);
setBatchingImplementation(batchedUpdatesImpl, discreteUpdates);

function computeComponentStackForErrorReporting(reactTag: number): string {
const fiber = getClosestInstanceFromNode(reactTag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ let batchedUpdatesImpl = function(fn, bookkeeping) {
let discreteUpdatesImpl = function(fn, a, b, c, d) {
return fn(a, b, c, d);
};
let batchedEventUpdatesImpl = batchedUpdatesImpl;

let isInsideEventHandler = false;
let isBatchingEventUpdates = false;

export function batchedUpdates(fn, bookkeeping) {
if (isInsideEventHandler) {
Expand All @@ -37,20 +35,6 @@ export function batchedUpdates(fn, bookkeeping) {
}
}

export function batchedEventUpdates(fn, a, b) {
if (isBatchingEventUpdates) {
// If we are currently inside another batch, we need to wait until it
// fully completes before restoring state.
return fn(a, b);
}
isBatchingEventUpdates = true;
try {
return batchedEventUpdatesImpl(fn, a, b);
} finally {
isBatchingEventUpdates = false;
}
}

export function discreteUpdates(fn, a, b, c, d) {
const prevIsInsideEventHandler = isInsideEventHandler;
isInsideEventHandler = true;
Expand All @@ -64,9 +48,7 @@ export function discreteUpdates(fn, a, b, c, d) {
export function setBatchingImplementation(
_batchedUpdatesImpl,
_discreteUpdatesImpl,
_batchedEventUpdatesImpl,
) {
batchedUpdatesImpl = _batchedUpdatesImpl;
discreteUpdatesImpl = _discreteUpdatesImpl;
batchedEventUpdatesImpl = _batchedEventUpdatesImpl;
}
5 changes: 0 additions & 5 deletions packages/react-reconciler/src/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {enableNewReconciler} from 'shared/ReactFeatureFlags';
import {
createContainer as createContainer_old,
updateContainer as updateContainer_old,
batchedEventUpdates as batchedEventUpdates_old,
batchedUpdates as batchedUpdates_old,
unbatchedUpdates as unbatchedUpdates_old,
deferredUpdates as deferredUpdates_old,
Expand Down Expand Up @@ -56,7 +55,6 @@ import {
import {
createContainer as createContainer_new,
updateContainer as updateContainer_new,
batchedEventUpdates as batchedEventUpdates_new,
batchedUpdates as batchedUpdates_new,
unbatchedUpdates as unbatchedUpdates_new,
deferredUpdates as deferredUpdates_new,
Expand Down Expand Up @@ -98,9 +96,6 @@ export const createContainer = enableNewReconciler
export const updateContainer = enableNewReconciler
? updateContainer_new
: updateContainer_old;
export const batchedEventUpdates = enableNewReconciler
? batchedEventUpdates_new
: batchedEventUpdates_old;
export const batchedUpdates = enableNewReconciler
? batchedUpdates_new
: batchedUpdates_old;
Expand Down
2 changes: 0 additions & 2 deletions packages/react-reconciler/src/ReactFiberReconciler.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
requestUpdateLane,
scheduleUpdateOnFiber,
flushRoot,
batchedEventUpdates,
batchedUpdates,
unbatchedUpdates,
flushSync,
Expand Down Expand Up @@ -327,7 +326,6 @@ export function updateContainer(
}

export {
batchedEventUpdates,
batchedUpdates,
unbatchedUpdates,
deferredUpdates,
Expand Down
2 changes: 0 additions & 2 deletions packages/react-reconciler/src/ReactFiberReconciler.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
requestUpdateLane,
scheduleUpdateOnFiber,
flushRoot,
batchedEventUpdates,
batchedUpdates,
unbatchedUpdates,
flushSync,
Expand Down Expand Up @@ -327,7 +326,6 @@ export function updateContainer(
}

export {
batchedEventUpdates,
batchedUpdates,
unbatchedUpdates,
deferredUpdates,
Expand Down
29 changes: 6 additions & 23 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,12 @@ const {

type ExecutionContext = number;

export const NoContext = /* */ 0b000000;
const BatchedContext = /* */ 0b000001;
const EventContext = /* */ 0b000010;
const LegacyUnbatchedContext = /* */ 0b000100;
const RenderContext = /* */ 0b001000;
const CommitContext = /* */ 0b010000;
export const RetryAfterError = /* */ 0b100000;
export const NoContext = /* */ 0b00000;
const BatchedContext = /* */ 0b00001;
const LegacyUnbatchedContext = /* */ 0b00010;
const RenderContext = /* */ 0b00100;
const CommitContext = /* */ 0b01000;
export const RetryAfterError = /* */ 0b10000;

type RootExitStatus = 0 | 1 | 2 | 3 | 4 | 5;
const RootIncomplete = 0;
Expand Down Expand Up @@ -1102,22 +1101,6 @@ export function batchedUpdates<A, R>(fn: A => R, a: A): R {
}
}

export function batchedEventUpdates<A, R>(fn: A => R, a: A): R {
const prevExecutionContext = executionContext;
executionContext |= EventContext;
try {
return fn(a);
} finally {
executionContext = prevExecutionContext;
// If there were legacy sync updates, flush them at the end of the outer
// most batchedUpdates-like method.
if (executionContext === NoContext) {
resetRenderTimer();
flushSyncCallbacksOnlyInLegacyMode();
}
}
}

export function discreteUpdates<A, B, C, D, R>(
fn: (A, B, C, D) => R,
a: A,
Expand Down
29 changes: 6 additions & 23 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,12 @@ const {

type ExecutionContext = number;

export const NoContext = /* */ 0b000000;
const BatchedContext = /* */ 0b000001;
const EventContext = /* */ 0b000010;
const LegacyUnbatchedContext = /* */ 0b000100;
const RenderContext = /* */ 0b001000;
const CommitContext = /* */ 0b010000;
export const RetryAfterError = /* */ 0b100000;
export const NoContext = /* */ 0b00000;
const BatchedContext = /* */ 0b00001;
const LegacyUnbatchedContext = /* */ 0b00010;
const RenderContext = /* */ 0b00100;
const CommitContext = /* */ 0b01000;
export const RetryAfterError = /* */ 0b10000;

type RootExitStatus = 0 | 1 | 2 | 3 | 4 | 5;
const RootIncomplete = 0;
Expand Down Expand Up @@ -1102,22 +1101,6 @@ export function batchedUpdates<A, R>(fn: A => R, a: A): R {
}
}

export function batchedEventUpdates<A, R>(fn: A => R, a: A): R {
const prevExecutionContext = executionContext;
executionContext |= EventContext;
try {
return fn(a);
} finally {
executionContext = prevExecutionContext;
// If there were legacy sync updates, flush them at the end of the outer
// most batchedUpdates-like method.
if (executionContext === NoContext) {
resetRenderTimer();
flushSyncCallbacksOnlyInLegacyMode();
}
}
}

export function discreteUpdates<A, B, C, D, R>(
fn: (A, B, C, D) => R,
a: A,
Expand Down

0 comments on commit c96761c

Please sign in to comment.