mirror of
https://github.com/status-im/status-react.git
synced 2025-01-23 09:19:59 +00:00
[performance] replace reduce by reduce-kv
For associative collections, using reduce-kv should give a small performance gain over reduce as there is no allocation of tuples for key/value pairs Signed-off-by: yenda <eric@status.im>
This commit is contained in:
parent
29eeb140b9
commit
70e889a03a
@ -44,12 +44,14 @@
|
||||
|
||||
(defn active-chats
|
||||
[contacts chats {:keys [public-key]}]
|
||||
(reduce (fn [acc [chat-id {:keys [is-active] :as chat}]]
|
||||
(if is-active
|
||||
(assoc acc chat-id (enrich-active-chat contacts chat public-key))
|
||||
acc))
|
||||
{}
|
||||
chats))
|
||||
(reduce-kv (fn [acc chat-id {:keys [is-active] :as chat}]
|
||||
(if is-active
|
||||
(assoc acc
|
||||
chat-id
|
||||
(enrich-active-chat contacts chat public-key))
|
||||
acc))
|
||||
{}
|
||||
chats))
|
||||
|
||||
(defn topic-by-current-chat
|
||||
[{:keys [current-chat-id chats] :as db}]
|
||||
|
@ -177,10 +177,10 @@
|
||||
|
||||
(defn enrich-contacts
|
||||
[contacts]
|
||||
(reduce (fn [acc [public-key contact]]
|
||||
(assoc acc public-key (enrich-contact contact)))
|
||||
{}
|
||||
contacts))
|
||||
(reduce-kv (fn [acc public-key contact]
|
||||
(assoc acc public-key (enrich-contact contact)))
|
||||
{}
|
||||
contacts))
|
||||
|
||||
(defn get-blocked-contacts
|
||||
[contacts]
|
||||
|
Loading…
x
Reference in New Issue
Block a user