Skip to content

Commit 4b4ab25

Browse files
committed
Delete fiberToFiberInstanceMap
It is now unused so we can save time and memory avoiding to maintain it.
1 parent 56de3e4 commit 4b4ab25

File tree

1 file changed

+1
-42
lines changed
  • packages/react-devtools-shared/src/backend/fiber

1 file changed

+1
-42
lines changed

packages/react-devtools-shared/src/backend/fiber/renderer.js

+1-42
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,7 @@ const knownEnvironmentNames: Set<string> = new Set();
744744
// Map of FiberRoot to their root FiberInstance.
745745
const rootToFiberInstanceMap: Map<FiberRoot, FiberInstance> = new Map();
746746

747-
// Map of one or more Fibers in a pair to their unique id number.
748-
// We track both Fibers to support Fast Refresh,
749-
// which may forcefully replace one of the pair as part of hot reloading.
750-
// In that case it's still important to be able to locate the previous ID during subsequent renders.
751-
const fiberToFiberInstanceMap: Map<Fiber, FiberInstance> = new Map();
752-
753-
// Map of id to one (arbitrary) Fiber in a pair.
747+
// Map of id to FiberInstance or VirtualInstance.
754748
// This Map is used to e.g. get the display name for a Fiber or schedule an update,
755749
// operations that should be the same whether the current and work-in-progress Fiber is used.
756750
const idToDevToolsInstanceMap: Map<number, FiberInstance | VirtualInstance> =
@@ -1331,10 +1325,6 @@ export function attach(
13311325
const newRoot = createFiberInstance(current);
13321326
rootToFiberInstanceMap.set(root, newRoot);
13331327
idToDevToolsInstanceMap.set(newRoot.id, newRoot);
1334-
fiberToFiberInstanceMap.set(current, newRoot);
1335-
if (alternate) {
1336-
fiberToFiberInstanceMap.set(alternate, newRoot);
1337-
}
13381328

13391329
// Before the traversals, remember to start tracking
13401330
// our path in case we have selection to restore.
@@ -2016,14 +2006,6 @@ export function attach(
20162006
} else {
20172007
fiberInstance = createFiberInstance(fiber);
20182008
}
2019-
// If this already exists behind a different FiberInstance, we intentionally
2020-
// override it here to claim the fiber as part of this new instance.
2021-
// E.g. if it was part of a reparenting.
2022-
fiberToFiberInstanceMap.set(fiber, fiberInstance);
2023-
const alternate = fiber.alternate;
2024-
if (alternate !== null && fiberToFiberInstanceMap.has(alternate)) {
2025-
fiberToFiberInstanceMap.set(alternate, fiberInstance);
2026-
}
20272009
idToDevToolsInstanceMap.set(fiberInstance.id, fiberInstance);
20282010

20292011
const id = fiberInstance.id;
@@ -2237,16 +2219,6 @@ export function attach(
22372219

22382220
idToDevToolsInstanceMap.delete(fiberInstance.id);
22392221

2240-
if (fiberToFiberInstanceMap.get(fiber) === fiberInstance) {
2241-
fiberToFiberInstanceMap.delete(fiber);
2242-
}
2243-
const {alternate} = fiber;
2244-
if (alternate !== null) {
2245-
if (fiberToFiberInstanceMap.get(alternate) === fiberInstance) {
2246-
fiberToFiberInstanceMap.delete(alternate);
2247-
}
2248-
}
2249-
22502222
untrackFiber(fiberInstance, fiber);
22512223
}
22522224

@@ -3084,9 +3056,6 @@ export function attach(
30843056
shouldResetChildren = true;
30853057
}
30863058

3087-
// Register the new alternate in case it's not already in.
3088-
fiberToFiberInstanceMap.set(nextChild, fiberInstance);
3089-
30903059
moveChild(fiberInstance, previousSiblingOfExistingInstance);
30913060

30923061
if (
@@ -3467,11 +3436,6 @@ export function attach(
34673436
const newRoot = createFiberInstance(current);
34683437
rootToFiberInstanceMap.set(root, newRoot);
34693438
idToDevToolsInstanceMap.set(newRoot.id, newRoot);
3470-
fiberToFiberInstanceMap.set(current, newRoot);
3471-
const alternate = current.alternate;
3472-
if (alternate) {
3473-
fiberToFiberInstanceMap.set(alternate, newRoot);
3474-
}
34753439
currentRoot = newRoot;
34763440
setRootPseudoKey(currentRoot.id, root.current);
34773441

@@ -3541,11 +3505,6 @@ export function attach(
35413505
rootInstance = createFiberInstance(current);
35423506
rootToFiberInstanceMap.set(root, rootInstance);
35433507
idToDevToolsInstanceMap.set(rootInstance.id, rootInstance);
3544-
fiberToFiberInstanceMap.set(current, rootInstance);
3545-
const alternate = current.alternate;
3546-
if (alternate) {
3547-
fiberToFiberInstanceMap.set(alternate, rootInstance);
3548-
}
35493508
} else {
35503509
prevFiber = rootInstance.data;
35513510
}

0 commit comments

Comments
 (0)