Skip to content

Commit

Permalink
Remove unnecessary update fields
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed Aug 26, 2020
1 parent a9e9d14 commit aa8f10b
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 62 deletions.
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberClassComponent.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const classComponentUpdater = {
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);

const update = createUpdate(eventTime, lane, suspenseConfig);
const update = createUpdate(eventTime, lane);
update.payload = payload;
if (callback !== undefined && callback !== null) {
if (__DEV__) {
Expand Down Expand Up @@ -230,7 +230,7 @@ const classComponentUpdater = {
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);

const update = createUpdate(eventTime, lane, suspenseConfig);
const update = createUpdate(eventTime, lane);
update.tag = ReplaceState;
update.payload = payload;

Expand Down Expand Up @@ -263,7 +263,7 @@ const classComponentUpdater = {
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);

const update = createUpdate(eventTime, lane, suspenseConfig);
const update = createUpdate(eventTime, lane);
update.tag = ForceUpdate;

if (callback !== undefined && callback !== null) {
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberClassComponent.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const classComponentUpdater = {
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);

const update = createUpdate(eventTime, lane, suspenseConfig);
const update = createUpdate(eventTime, lane);
update.payload = payload;
if (callback !== undefined && callback !== null) {
if (__DEV__) {
Expand Down Expand Up @@ -230,7 +230,7 @@ const classComponentUpdater = {
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);

const update = createUpdate(eventTime, lane, suspenseConfig);
const update = createUpdate(eventTime, lane);
update.tag = ReplaceState;
update.payload = payload;

Expand Down Expand Up @@ -263,7 +263,7 @@ const classComponentUpdater = {
const suspenseConfig = requestCurrentSuspenseConfig();
const lane = requestUpdateLane(fiber, suspenseConfig);

const update = createUpdate(eventTime, lane, suspenseConfig);
const update = createUpdate(eventTime, lane);
update.tag = ForceUpdate;

if (callback !== undefined && callback !== null) {
Expand Down
12 changes: 0 additions & 12 deletions packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ import {markStateUpdateScheduled} from './SchedulingProfiler';
const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals;

type Update<S, A> = {|
// TODO: Temporary field. Will remove this by storing a map of
// transition -> start time on the root.
eventTime: number,
lane: Lane,
suspenseConfig: null | SuspenseConfig,
action: A,
eagerReducer: ((S, A) => S) | null,
eagerState: S | null,
Expand Down Expand Up @@ -714,17 +710,13 @@ function updateReducer<S, I, A>(
let newBaseQueueLast = null;
let update = first;
do {
const suspenseConfig = update.suspenseConfig;
const updateLane = update.lane;
const updateEventTime = update.eventTime;
if (!isSubsetOfLanes(renderLanes, updateLane)) {
// Priority is insufficient. Skip this update. If this is the first
// skipped update, the previous update/state is the new base
// update/state.
const clone: Update<S, A> = {
eventTime: updateEventTime,
lane: updateLane,
suspenseConfig: suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
Expand All @@ -749,12 +741,10 @@ function updateReducer<S, I, A>(

if (newBaseQueueLast !== null) {
const clone: Update<S, A> = {
eventTime: updateEventTime,
// This update is going to be committed so we never want uncommit
// it. Using NoLane works because 0 is a subset of all bitmasks, so
// this will never be skipped by the check above.
lane: NoLane,
suspenseConfig: update.suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
Expand Down Expand Up @@ -1699,9 +1689,7 @@ function dispatchAction<S, A>(
const lane = requestUpdateLane(fiber, suspenseConfig);

const update: Update<S, A> = {
eventTime,
lane,
suspenseConfig,
action,
eagerReducer: null,
eagerState: null,
Expand Down
12 changes: 0 additions & 12 deletions packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ import {markStateUpdateScheduled} from './SchedulingProfiler';
const {ReactCurrentDispatcher, ReactCurrentBatchConfig} = ReactSharedInternals;

type Update<S, A> = {|
// TODO: Temporary field. Will remove this by storing a map of
// transition -> start time on the root.
eventTime: number,
lane: Lane,
suspenseConfig: null | SuspenseConfig,
action: A,
eagerReducer: ((S, A) => S) | null,
eagerState: S | null,
Expand Down Expand Up @@ -713,17 +709,13 @@ function updateReducer<S, I, A>(
let newBaseQueueLast = null;
let update = first;
do {
const suspenseConfig = update.suspenseConfig;
const updateLane = update.lane;
const updateEventTime = update.eventTime;
if (!isSubsetOfLanes(renderLanes, updateLane)) {
// Priority is insufficient. Skip this update. If this is the first
// skipped update, the previous update/state is the new base
// update/state.
const clone: Update<S, A> = {
eventTime: updateEventTime,
lane: updateLane,
suspenseConfig: suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
Expand All @@ -748,12 +740,10 @@ function updateReducer<S, I, A>(

if (newBaseQueueLast !== null) {
const clone: Update<S, A> = {
eventTime: updateEventTime,
// This update is going to be committed so we never want uncommit
// it. Using NoLane works because 0 is a subset of all bitmasks, so
// this will never be skipped by the check above.
lane: NoLane,
suspenseConfig: update.suspenseConfig,
action: update.action,
eagerReducer: update.eagerReducer,
eagerState: update.eagerState,
Expand Down Expand Up @@ -1697,9 +1687,7 @@ function dispatchAction<S, A>(
const lane = requestUpdateLane(fiber, suspenseConfig);

const update: Update<S, A> = {
eventTime,
lane,
suspenseConfig,
action,
eagerReducer: null,
eagerState: null,
Expand Down
1 change: 0 additions & 1 deletion packages/react-reconciler/src/ReactFiberNewContext.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ export function propagateContextChange(
const update = createUpdate(
NoTimestamp,
pickArbitraryLane(renderLanes),
null,
);
update.tag = ForceUpdate;
// TODO: Because we don't have a work-in-progress, this will add the
Expand Down
1 change: 0 additions & 1 deletion packages/react-reconciler/src/ReactFiberNewContext.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ export function propagateContextChange(
const update = createUpdate(
NoTimestamp,
pickArbitraryLane(renderLanes),
null,
);
update.tag = ForceUpdate;
// TODO: Because we don't have a work-in-progress, this will add the
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberReconciler.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export function updateContainer(
}
}

const update = createUpdate(eventTime, lane, suspenseConfig);
const update = createUpdate(eventTime, lane);
// Caution: React DevTools currently depends on this property
// being called "element".
update.payload = {element};
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberReconciler.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export function updateContainer(
}
}

const update = createUpdate(eventTime, lane, suspenseConfig);
const update = createUpdate(eventTime, lane);
// Caution: React DevTools currently depends on this property
// being called "element".
update.payload = {element};
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberThrow.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function createRootErrorUpdate(
errorInfo: CapturedValue<mixed>,
lane: Lane,
): Update<mixed> {
const update = createUpdate(NoTimestamp, lane, null);
const update = createUpdate(NoTimestamp, lane);
// Unmount the root by rendering null.
update.tag = CaptureUpdate;
// Caution: React DevTools currently depends on this property
Expand All @@ -95,7 +95,7 @@ function createClassErrorUpdate(
errorInfo: CapturedValue<mixed>,
lane: Lane,
): Update<mixed> {
const update = createUpdate(NoTimestamp, lane, null);
const update = createUpdate(NoTimestamp, lane);
update.tag = CaptureUpdate;
const getDerivedStateFromError = fiber.type.getDerivedStateFromError;
if (typeof getDerivedStateFromError === 'function') {
Expand Down Expand Up @@ -274,7 +274,7 @@ function throwException(
// When we try rendering again, we should not reuse the current fiber,
// since it's known to be in an inconsistent state. Use a force update to
// prevent a bail out.
const update = createUpdate(NoTimestamp, SyncLane, null);
const update = createUpdate(NoTimestamp, SyncLane);
update.tag = ForceUpdate;
enqueueUpdate(sourceFiber, update);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberThrow.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function createRootErrorUpdate(
errorInfo: CapturedValue<mixed>,
lane: Lane,
): Update<mixed> {
const update = createUpdate(NoTimestamp, lane, null);
const update = createUpdate(NoTimestamp, lane);
// Unmount the root by rendering null.
update.tag = CaptureUpdate;
// Caution: React DevTools currently depends on this property
Expand All @@ -95,7 +95,7 @@ function createClassErrorUpdate(
errorInfo: CapturedValue<mixed>,
lane: Lane,
): Update<mixed> {
const update = createUpdate(NoTimestamp, lane, null);
const update = createUpdate(NoTimestamp, lane);
update.tag = CaptureUpdate;
const getDerivedStateFromError = fiber.type.getDerivedStateFromError;
if (typeof getDerivedStateFromError === 'function') {
Expand Down Expand Up @@ -276,7 +276,7 @@ function throwException(
// When we try rendering again, we should not reuse the current fiber,
// since it's known to be in an inconsistent state. Use a force update to
// prevent a bail out.
const update = createUpdate(NoTimestamp, SyncLane, null);
const update = createUpdate(NoTimestamp, SyncLane);
update.tag = ForceUpdate;
enqueueUpdate(sourceFiber, update);
}
Expand Down
12 changes: 1 addition & 11 deletions packages/react-reconciler/src/ReactUpdateQueue.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@

import type {Fiber} from './ReactInternalTypes';
import type {Lanes, Lane} from './ReactFiberLane';
import type {SuspenseConfig} from './ReactFiberSuspenseConfig';

import {NoLane, NoLanes, isSubsetOfLanes, mergeLanes} from './ReactFiberLane';
import {
Expand All @@ -109,7 +108,6 @@ export type Update<State> = {|
// transition -> event time on the root.
eventTime: number,
lane: Lane,
suspenseConfig: null | SuspenseConfig,

tag: 0 | 1 | 2 | 3,
payload: any,
Expand Down Expand Up @@ -183,15 +181,10 @@ export function cloneUpdateQueue<State>(
}
}

export function createUpdate(
eventTime: number,
lane: Lane,
suspenseConfig: null | SuspenseConfig,
): Update<*> {
export function createUpdate(eventTime: number, lane: Lane): Update<*> {
const update: Update<*> = {
eventTime,
lane,
suspenseConfig,

tag: UpdateState,
payload: null,
Expand Down Expand Up @@ -266,7 +259,6 @@ export function enqueueCapturedUpdate<State>(
const clone: Update<State> = {
eventTime: update.eventTime,
lane: update.lane,
suspenseConfig: update.suspenseConfig,

tag: update.tag,
payload: update.payload,
Expand Down Expand Up @@ -479,7 +471,6 @@ export function processUpdateQueue<State>(
const clone: Update<State> = {
eventTime: updateEventTime,
lane: updateLane,
suspenseConfig: update.suspenseConfig,

tag: update.tag,
payload: update.payload,
Expand All @@ -505,7 +496,6 @@ export function processUpdateQueue<State>(
// it. Using NoLane works because 0 is a subset of all bitmasks, so
// this will never be skipped by the check above.
lane: NoLane,
suspenseConfig: update.suspenseConfig,

tag: update.tag,
payload: update.payload,
Expand Down
12 changes: 1 addition & 11 deletions packages/react-reconciler/src/ReactUpdateQueue.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@

import type {Fiber} from './ReactInternalTypes';
import type {Lanes, Lane} from './ReactFiberLane';
import type {SuspenseConfig} from './ReactFiberSuspenseConfig';

import {NoLane, NoLanes, isSubsetOfLanes, mergeLanes} from './ReactFiberLane';
import {
Expand All @@ -109,7 +108,6 @@ export type Update<State> = {|
// transition -> event time on the root.
eventTime: number,
lane: Lane,
suspenseConfig: null | SuspenseConfig,

tag: 0 | 1 | 2 | 3,
payload: any,
Expand Down Expand Up @@ -183,15 +181,10 @@ export function cloneUpdateQueue<State>(
}
}

export function createUpdate(
eventTime: number,
lane: Lane,
suspenseConfig: null | SuspenseConfig,
): Update<*> {
export function createUpdate(eventTime: number, lane: Lane): Update<*> {
const update: Update<*> = {
eventTime,
lane,
suspenseConfig,

tag: UpdateState,
payload: null,
Expand Down Expand Up @@ -266,7 +259,6 @@ export function enqueueCapturedUpdate<State>(
const clone: Update<State> = {
eventTime: update.eventTime,
lane: update.lane,
suspenseConfig: update.suspenseConfig,

tag: update.tag,
payload: update.payload,
Expand Down Expand Up @@ -479,7 +471,6 @@ export function processUpdateQueue<State>(
const clone: Update<State> = {
eventTime: updateEventTime,
lane: updateLane,
suspenseConfig: update.suspenseConfig,

tag: update.tag,
payload: update.payload,
Expand All @@ -505,7 +496,6 @@ export function processUpdateQueue<State>(
// it. Using NoLane works because 0 is a subset of all bitmasks, so
// this will never be skipped by the check above.
lane: NoLane,
suspenseConfig: update.suspenseConfig,

tag: update.tag,
payload: update.payload,
Expand Down

0 comments on commit aa8f10b

Please sign in to comment.