Skip to content

Commit b766904

Browse files
authored
Use Map instead of object as map in ReactNativeComponentTree (facebook#16107)
Real Maps should now be used in RN JS engines. In theory this should be faster (but might not actually be in practice), and it avoids hitting upper bounds of property max counts. We don't use these types of Maps in Fabric.
1 parent d2d9b1f commit b766904

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/react-native-renderer/src/ReactNativeComponentTree.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
import invariant from 'shared/invariant';
99

10-
const instanceCache = {};
11-
const instanceProps = {};
10+
const instanceCache = new Map();
11+
const instanceProps = new Map();
1212

1313
export function precacheFiberNode(hostInst, tag) {
14-
instanceCache[tag] = hostInst;
14+
instanceCache.set(tag, hostInst);
1515
}
1616

1717
export function uncacheFiberNode(tag) {
18-
delete instanceCache[tag];
19-
delete instanceProps[tag];
18+
instanceCache.delete(tag);
19+
instanceProps.delete(tag);
2020
}
2121

2222
function getInstanceFromTag(tag) {
23-
return instanceCache[tag] || null;
23+
return instanceCache.get(tag) || null;
2424
}
2525

2626
function getTagFromInstance(inst) {
@@ -39,9 +39,9 @@ export {
3939
};
4040

4141
export function getFiberCurrentPropsFromNode(stateNode) {
42-
return instanceProps[stateNode._nativeTag] || null;
42+
return instanceProps.get(stateNode._nativeTag) || null;
4343
}
4444

4545
export function updateFiberProps(tag, props) {
46-
instanceProps[tag] = props;
46+
instanceProps.set(tag, props);
4747
}

0 commit comments

Comments
 (0)