Hi Leon,

If you use merge a lot, check out data.int-map
<https://github.com/clojure/data.int-map>, it only supports integer keys,
but is optimized for merges.

Merge is essentially (reduce conj) so you could see if using a transient
<http://clojure.org/transients> version of the original map and merging
into it works for you.

~M


On Fri, Jun 12, 2015 at 4:20 AM, Leon Grapenthin <grapenthinl...@gmail.com>
wrote:

> If I want merge in an algorithm where it is often the case that the new
> map has the same keys as the old map, I'd assume using the new map as a
> replacement is faster in those cases.
>
> Of course comparing the keys costs and I'd like to know which is the
> fastest way.
>
> Can I do (= (keys old-map) (keys new-map)) or are the orders not
> guaranteed?
>
> I see an alternative in (every? new-map (keys old-map)) which would also
> account for cases where the keysets are different but old-map would be
> completely replaced by the merge.
>
> Which one would you recommend, performance wise?
>
> On a side note: I noticed Clojures merge merges a map onto nil by
> replacing nil with an empty map. Wouldn't it be faster if it returned the
> map right away? Should I write a ticket?
>
> Kind regards,
>  Leon.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-Mohit Thatte

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to