From 15015dacd7f0f36f7cc1514d9c58ab553fa5ed09 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Thu, 27 May 2021 20:48:55 +0800 Subject: [PATCH] Performance: don't spread in 'reduce' --- ui/redux/reducers/tags.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ui/redux/reducers/tags.js b/ui/redux/reducers/tags.js index 0001a3f8c..646ecac1a 100644 --- a/ui/redux/reducers/tags.js +++ b/ui/redux/reducers/tags.js @@ -4,13 +4,10 @@ import { ACTIONS as LBRY_REDUX_ACTIONS, DEFAULT_KNOWN_TAGS, DEFAULT_FOLLOWED_TAG import { handleActions } from 'util/redux-utils'; function getDefaultKnownTags() { - return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce( - (tagsMap, tag) => ({ - ...tagsMap, - [tag]: { name: tag }, - }), - {} - ); + return DEFAULT_FOLLOWED_TAGS.concat(DEFAULT_KNOWN_TAGS).reduce((tagsMap, tag) => { + tagsMap[tag] = { name: tag }; + return tagsMap; + }, {}); } const defaultState: TagState = { @@ -27,7 +24,7 @@ export default handleActions( let newFollowedTags = followedTags.slice(); if (newFollowedTags.includes(name)) { - newFollowedTags = newFollowedTags.filter(tag => tag !== name); + newFollowedTags = newFollowedTags.filter((tag) => tag !== name); } else { newFollowedTags.push(name); } @@ -57,7 +54,7 @@ export default handleActions( let newKnownTags = { ...knownTags }; delete newKnownTags[name]; - const newFollowedTags = followedTags.filter(tag => tag !== name); + const newFollowedTags = followedTags.filter((tag) => tag !== name); return { ...state,