Revert CommitInfo to avoid extra allocation
I added this when I thought we might support interleaved commits, but we don't.
Andrew Clark committed
Jan 10, 2017 at 17:14 UTC
b59cb4ae011da039bb3efb164cf86ab75204901c
7 files changed
+24
-26
src/renderers/dom/fiber/ReactDOMFiber.js
+11
-13
@@ -67,10 +67,9 @@ type HostContextDev = {
67
};
68
type HostContextProd = string;
69
type HostContext = HostContextDev | HostContextProd;
70
-type CommitInfo = {
71
- eventsEnabled: boolean,
72
- selectionInformation: mixed,
73
-};
70
+
71
+let eventsEnabled : ?boolean = null;
72
+let selectionInformation : ?mixed = null;
73
74
var ELEMENT_NODE_TYPE = 1;
75
var DOC_NODE_TYPE = 9;
@@ -138,18 +137,17 @@ var DOMRenderer = ReactFiberReconciler({
137
return getChildNamespace(parentNamespace, type);
138
},
139
141
- prepareForCommit() : CommitInfo {
142
- const eventsEnabled = ReactBrowserEventEmitter.isEnabled();
140
+ prepareForCommit() : void {
141
+ eventsEnabled = ReactBrowserEventEmitter.isEnabled();
142
+ selectionInformation = ReactInputSelection.getSelectionInformation();
143
ReactBrowserEventEmitter.setEnabled(false);
144
- return {
145
- eventsEnabled,
146
- selectionInformation: ReactInputSelection.getSelectionInformation(),
147
- };
144
},
145
150
- resetAfterCommit(commitInfo : CommitInfo) : void {
151
- ReactInputSelection.restoreSelection(commitInfo.selectionInformation);
152
- ReactBrowserEventEmitter.setEnabled(commitInfo.eventsEnabled);
146
+ resetAfterCommit() : void {
147
+ ReactInputSelection.restoreSelection(selectionInformation);
148
+ selectionInformation = null;
149
+ ReactBrowserEventEmitter.setEnabled(eventsEnabled);
150
+ eventsEnabled = null;
151
},
152
153
createInstance(
src/renderers/shared/fiber/ReactFiberBeginWork.js
+2
-2
@@ -71,8 +71,8 @@ if (__DEV__) {
71
var warnedAboutStatelessRefs = {};
72
}
73
74
-module.exports = function<T, P, I, TI, C, CX, CI>(
75
- config : HostConfig<T, P, I, TI, C, CX, CI>,
74
+module.exports = function<T, P, I, TI, C, CX>(
75
+ config : HostConfig<T, P, I, TI, C, CX>,
76
hostContext : HostContext<C, CX>,
77
scheduleUpdate : (fiber : Fiber, priorityLevel : PriorityLevel) => void,
78
getPriorityContext : () => PriorityLevel,
src/renderers/shared/fiber/ReactFiberCommitWork.js
+2
-2
@@ -34,8 +34,8 @@ var {
34
ContentReset,
35
} = require('ReactTypeOfSideEffect');
36
37
-module.exports = function<T, P, I, TI, C, CX, CI>(
38
- config : HostConfig<T, P, I, TI, C, CX, CI>,
37
+module.exports = function<T, P, I, TI, C, CX>(
38
+ config : HostConfig<T, P, I, TI, C, CX>,
39
hostContext : HostContext<C, CX>,
40
captureError : (failedFiber : Fiber, error: Error) => ?Fiber
41
) {
src/renderers/shared/fiber/ReactFiberCompleteWork.js
+2
-2
@@ -46,8 +46,8 @@ if (__DEV__) {
46
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
47
}
48
49
-module.exports = function<T, P, I, TI, C, CX, CI>(
50
- config : HostConfig<T, P, I, TI, C, CX, CI>,
49
+module.exports = function<T, P, I, TI, C, CX>(
50
+ config : HostConfig<T, P, I, TI, C, CX>,
51
hostContext : HostContext<C, CX>,
52
) {
53
const {
src/renderers/shared/fiber/ReactFiberHostContext.js
+2
-2
@@ -34,8 +34,8 @@ export type HostContext<C, CX> = {
34
resetHostContainer() : void,
35
};
36
37
-module.exports = function<T, P, I, TI, C, CX, CI>(
38
- config : HostConfig<T, P, I, TI, C, CX, CI>
37
+module.exports = function<T, P, I, TI, C, CX>(
38
+ config : HostConfig<T, P, I, TI, C, CX>
39
) : HostContext<C, CX> {
40
const {
41
getChildHostContext,
src/renderers/shared/fiber/ReactFiberReconciler.js
+4
-4
@@ -43,7 +43,7 @@ export type Deadline = {
43
44
type OpaqueNode = Fiber;
45
46
-export type HostConfig<T, P, I, TI, C, CX, CI> = {
46
+export type HostConfig<T, P, I, TI, C, CX> = {
47
48
getRootHostContext(rootContainerInstance : C) : CX,
49
getChildHostContext(parentHostContext : CX, type : T) : CX,
@@ -69,8 +69,8 @@ export type HostConfig<T, P, I, TI, C, CX, CI> = {
69
scheduleAnimationCallback(callback : () => void) : void,
70
scheduleDeferredCallback(callback : (deadline : Deadline) => void) : void,
71
72
- prepareForCommit() : CI,
73
- resetAfterCommit(commitInfo : CI) : void,
72
+ prepareForCommit() : void,
73
+ resetAfterCommit() : void,
74
75
useSyncScheduling ?: boolean,
76
};
@@ -101,7 +101,7 @@ getContextForSubtree._injectFiber(function(fiber : Fiber) {
101
parentContext;
102
});
103
104
-module.exports = function<T, P, I, TI, C, CX, CI>(config : HostConfig<T, P, I, TI, C, CX, CI>) : Reconciler<C, I, TI> {
104
+module.exports = function<T, P, I, TI, C, CX>(config : HostConfig<T, P, I, TI, C, CX>) : Reconciler<C, I, TI> {
105
106
var {
107
scheduleUpdate,
src/renderers/shared/fiber/ReactFiberScheduler.js
+1
-1
@@ -74,7 +74,7 @@ if (__DEV__) {
74
75
var timeHeuristicForUnitOfWork = 1;
76
77
-module.exports = function<T, P, I, TI, C, CX, CI>(config : HostConfig<T, P, I, TI, C, CX, CI>) {
77
+module.exports = function<T, P, I, TI, C, CX>(config : HostConfig<T, P, I, TI, C, CX>) {
78
const hostContext = ReactFiberHostContext(config);
79
const { popHostContainer, popHostContext, resetHostContainer } = hostContext;
80
const { beginWork, beginFailedWork } = ReactFiberBeginWork(