Use set instead of array to keep list of supported plugins per client
Summary: Use set instead of array to keep list of supported plugins per client. It is not used as array anyway, in most places it is used to determine whether a plugin is supported or not and it's much faster to use set for that. Reviewed By: priteshrnandgaonkar Differential Revision: D29200673 fbshipit-source-id: 5f3c404a1a668c153867d7c1b6c223941f0b3b36
This commit is contained in:
committed by
Facebook GitHub Bot
parent
280c612157
commit
fd9b5cc94d
@@ -619,11 +619,13 @@ export function determinePluginsToProcess(
|
||||
}
|
||||
const selectedFilteredPlugins = client
|
||||
? selectedPlugins.length > 0
|
||||
? client.plugins.filter((plugin) => selectedPlugins.includes(plugin))
|
||||
? Array.from(client.plugins).filter((plugin) =>
|
||||
selectedPlugins.includes(plugin),
|
||||
)
|
||||
: client.plugins
|
||||
: [];
|
||||
for (const plugin of selectedFilteredPlugins) {
|
||||
if (!client.plugins.includes(plugin)) {
|
||||
if (!client.plugins.has(plugin)) {
|
||||
// Ignore clients which doesn't support the selected plugins.
|
||||
continue;
|
||||
}
|
||||
@@ -827,7 +829,7 @@ export function importDataToStore(source: string, data: string, store: Store) {
|
||||
|
||||
clients.forEach((client: {id: string; query: ClientQuery}) => {
|
||||
const sandyPluginStates = json.pluginStates2[client.id] || {};
|
||||
const clientPlugins: Array<string> = [
|
||||
const clientPlugins: Set<string> = new Set([
|
||||
...keys
|
||||
.filter((key) => {
|
||||
const plugin = deconstructPluginKey(key);
|
||||
@@ -835,7 +837,7 @@ export function importDataToStore(source: string, data: string, store: Store) {
|
||||
})
|
||||
.map((pluginKey) => deconstructPluginKey(pluginKey).pluginName),
|
||||
...Object.keys(sandyPluginStates),
|
||||
];
|
||||
]);
|
||||
store.dispatch({
|
||||
type: 'NEW_CLIENT',
|
||||
payload: new Client(
|
||||
|
||||
Reference in New Issue
Block a user