mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-06 05:45:03 +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,9 +44,11 @@
|
||||
|
||||
(defn active-chats
|
||||
[contacts chats {:keys [public-key]}]
|
||||
(reduce (fn [acc [chat-id {:keys [is-active] :as chat}]]
|
||||
(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))
|
||||
(assoc acc
|
||||
chat-id
|
||||
(enrich-active-chat contacts chat public-key))
|
||||
acc))
|
||||
{}
|
||||
chats))
|
||||
|
@ -177,7 +177,7 @@
|
||||
|
||||
(defn enrich-contacts
|
||||
[contacts]
|
||||
(reduce (fn [acc [public-key contact]]
|
||||
(reduce-kv (fn [acc public-key contact]
|
||||
(assoc acc public-key (enrich-contact contact)))
|
||||
{}
|
||||
contacts))
|
||||
|
Loading…
x
Reference in New Issue
Block a user