From 15b964f795ed5a1c4441b04b81e85d830b60c7ef Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Tue, 23 May 2023 12:01:59 +0300 Subject: [PATCH 1/4] Remove unnecessary array cloning --- packages/data/src/redux-store/metadata/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/data/src/redux-store/metadata/selectors.js b/packages/data/src/redux-store/metadata/selectors.js index 4e5a999567302..8e8f41ea7cada 100644 --- a/packages/data/src/redux-store/metadata/selectors.js +++ b/packages/data/src/redux-store/metadata/selectors.js @@ -140,7 +140,7 @@ export function getCachedResolvers( state ) { * @return {boolean} True if one or more selectors are resolving, false otherwise. */ export function hasResolvingSelectors( state ) { - return [ ...Object.values( state ) ].some( ( selectorState ) => + return Object.values( state ).some( ( selectorState ) => [ ...selectorState._map.values() ].some( ( resolution ) => resolution[ 1 ]?.status === 'resolving' ) From 7cc91b6d104bdd0aa564c3339f449284b1cdd041 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Tue, 23 May 2023 12:04:39 +0300 Subject: [PATCH 2/4] Document internal property usage --- packages/data/src/redux-store/metadata/selectors.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/data/src/redux-store/metadata/selectors.js b/packages/data/src/redux-store/metadata/selectors.js index 8e8f41ea7cada..22112b0802d15 100644 --- a/packages/data/src/redux-store/metadata/selectors.js +++ b/packages/data/src/redux-store/metadata/selectors.js @@ -141,6 +141,13 @@ export function getCachedResolvers( state ) { */ export function hasResolvingSelectors( state ) { return Object.values( state ).some( ( selectorState ) => + /** + * This uses the internal `_map` property of `EquivalentKeyMap` for + * optimization purposes, since the `EquivalentKeyMap` implementation + * does not support a `.some()` implementation. + * + * @see https://github.com/aduth/equivalent-key-map + */ [ ...selectorState._map.values() ].some( ( resolution ) => resolution[ 1 ]?.status === 'resolving' ) From 795937e597ee91dd1c605395b68733837a94f08d Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Tue, 23 May 2023 13:06:04 +0300 Subject: [PATCH 3/4] Use Array.from() instead of spread --- packages/data/src/redux-store/metadata/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/data/src/redux-store/metadata/selectors.js b/packages/data/src/redux-store/metadata/selectors.js index 22112b0802d15..e809f9a646455 100644 --- a/packages/data/src/redux-store/metadata/selectors.js +++ b/packages/data/src/redux-store/metadata/selectors.js @@ -148,7 +148,7 @@ export function hasResolvingSelectors( state ) { * * @see https://github.com/aduth/equivalent-key-map */ - [ ...selectorState._map.values() ].some( + Array.from( selectorState._map ).some( ( resolution ) => resolution[ 1 ]?.status === 'resolving' ) ); From 0a2b6793a95f9a7f1c8399636617019b00b7bbe6 Mon Sep 17 00:00:00 2001 From: Marin Atanasov Date: Tue, 23 May 2023 13:07:24 +0300 Subject: [PATCH 4/4] Correct docs --- packages/data/src/redux-store/metadata/selectors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/data/src/redux-store/metadata/selectors.js b/packages/data/src/redux-store/metadata/selectors.js index e809f9a646455..6cde6ec54b24e 100644 --- a/packages/data/src/redux-store/metadata/selectors.js +++ b/packages/data/src/redux-store/metadata/selectors.js @@ -144,11 +144,11 @@ export function hasResolvingSelectors( state ) { /** * This uses the internal `_map` property of `EquivalentKeyMap` for * optimization purposes, since the `EquivalentKeyMap` implementation - * does not support a `.some()` implementation. + * does not support a `.values()` implementation. * * @see https://github.com/aduth/equivalent-key-map */ - Array.from( selectorState._map ).some( + Array.from( selectorState._map.values() ).some( ( resolution ) => resolution[ 1 ]?.status === 'resolving' ) );