From 1af4325e8fe70b6f2cdf18b1d41de69af82c7aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Tue, 19 Oct 2021 12:27:41 +0200 Subject: [PATCH] :recycle: Do a small performance refactor --- common/src/app/common/types/interactions.cljc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/common/src/app/common/types/interactions.cljc b/common/src/app/common/types/interactions.cljc index f7723ab31..ebbc81e70 100644 --- a/common/src/app/common/types/interactions.cljc +++ b/common/src/app/common/types/interactions.cljc @@ -347,14 +347,14 @@ in the map nor in the objects tree." [interactions ids-map objects] (when (some? interactions) - (->> interactions - (filterv (fn [interaction] - (let [destination (:destination interaction)] - (or (nil? destination) - (contains? ids-map destination) - (contains? objects destination))))) - (mapv (fn [interaction] - (d/update-when interaction :destination #(get ids-map % %))))))) + (let [xform (comp (filter (fn [interaction] + (let [destination (:destination interaction)] + (or (nil? destination) + (contains? ids-map destination) + (contains? objects destination))))) + (map (fn [interaction] + (d/update-when interaction :destination #(get ids-map % %)))))] + (into [] xform interactions)))) (defn actionable? "Check if there is any interaction that is clickable by the user"