Skip to content

Commit

Permalink
Revert "Use collection key value map instead of recomputing everytime"
Browse files Browse the repository at this point in the history
  • Loading branch information
tgolen authored Aug 30, 2023
1 parent 3fa41cd commit 4a1d2e4
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/Onyx.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ let lastConnectionID = 0;
// Holds a mapping of all the react components that want their state subscribed to a store key
const callbackToStateMapping = {};

// Keeps a copy of the values of the onyx collection keys as a map for faster lookups
let onyxCollectionKeyMap = {};
// Stores all of the keys that Onyx can use. Must be defined in init().
let onyxKeys = {};

// Holds a list of keys that have been directly subscribed to or recently modified from least to most recent
let recentlyAccessedKeys = [];
Expand Down Expand Up @@ -141,7 +141,7 @@ function getAllKeys() {
* @returns {Boolean}
*/
function isCollectionKey(key) {
return onyxCollectionKeyMap.has(key);
return _.contains(_.values(onyxKeys.COLLECTION), key);
}

/**
Expand Down Expand Up @@ -1392,13 +1392,8 @@ function init({
cache.setRecentKeysLimit(maxCachedKeysCount);
}

// We need the value of the collection keys later for checking if a
// key is a collection. We store it in a map for faster lookup.
const collectionValues = _.values(keys.COLLECTION);
onyxCollectionKeyMap = _.reduce(collectionValues, (acc, val) => {
acc.set(val, true);
return acc;
}, new Map());
// Let Onyx know about all of our keys
onyxKeys = keys;

// Set our default key states to use when initializing and clearing Onyx data
defaultKeyStates = initialKeyStates;
Expand Down

0 comments on commit 4a1d2e4

Please sign in to comment.