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,12 +44,14 @@
|
|||||||
|
|
||||||
(defn active-chats
|
(defn active-chats
|
||||||
[contacts chats {:keys [public-key]}]
|
[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
|
(if is-active
|
||||||
(assoc acc chat-id (enrich-active-chat contacts chat public-key))
|
(assoc acc
|
||||||
acc))
|
chat-id
|
||||||
{}
|
(enrich-active-chat contacts chat public-key))
|
||||||
chats))
|
acc))
|
||||||
|
{}
|
||||||
|
chats))
|
||||||
|
|
||||||
(defn topic-by-current-chat
|
(defn topic-by-current-chat
|
||||||
[{:keys [current-chat-id chats] :as db}]
|
[{:keys [current-chat-id chats] :as db}]
|
||||||
|
@ -177,10 +177,10 @@
|
|||||||
|
|
||||||
(defn enrich-contacts
|
(defn enrich-contacts
|
||||||
[contacts]
|
[contacts]
|
||||||
(reduce (fn [acc [public-key contact]]
|
(reduce-kv (fn [acc public-key contact]
|
||||||
(assoc acc public-key (enrich-contact contact)))
|
(assoc acc public-key (enrich-contact contact)))
|
||||||
{}
|
{}
|
||||||
contacts))
|
contacts))
|
||||||
|
|
||||||
(defn get-blocked-contacts
|
(defn get-blocked-contacts
|
||||||
[contacts]
|
[contacts]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user