Skip to content

Commit

Permalink
Use Map instead of object as map in ReactNativeComponentTree (faceboo…
Browse files Browse the repository at this point in the history
…k#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.
  • Loading branch information
sebmarkbage committed Jul 11, 2019
1 parent d2d9b1f commit b766904
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/react-native-renderer/src/ReactNativeComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@

import invariant from 'shared/invariant';

const instanceCache = {};
const instanceProps = {};
const instanceCache = new Map();
const instanceProps = new Map();

export function precacheFiberNode(hostInst, tag) {
instanceCache[tag] = hostInst;
instanceCache.set(tag, hostInst);
}

export function uncacheFiberNode(tag) {
delete instanceCache[tag];
delete instanceProps[tag];
instanceCache.delete(tag);
instanceProps.delete(tag);
}

function getInstanceFromTag(tag) {
return instanceCache[tag] || null;
return instanceCache.get(tag) || null;
}

function getTagFromInstance(inst) {
Expand All @@ -39,9 +39,9 @@ export {
};

export function getFiberCurrentPropsFromNode(stateNode) {
return instanceProps[stateNode._nativeTag] || null;
return instanceProps.get(stateNode._nativeTag) || null;
}

export function updateFiberProps(tag, props) {
instanceProps[tag] = props;
instanceProps.set(tag, props);
}

0 comments on commit b766904

Please sign in to comment.