We're updating the issue view to help you get more done. 

reduce-kv on hash-maps or array-maps don't consistently execute the intended fastpath

Description

https://github.com/clojure/clojure/blob/010864f/src/clj/clojure/core.clj#L6553-L6562

Because PHMs implement clojure.lang.IKVReduce and IPersistentMap, they have nondeterministic dispatch through the protocol that backs reduce-kv (clojure.core.protocols/IKVReduce).

A potential way to solve this is to add an instance check for clojure.lang.IKVReduce inside `reduce-kv` (This is similar to how reduce checks for IReduceInit)

Another approach is to extend the protocol to PersistentHashMap and PersistentArrayMap directly (in addition to preserving the existing extensions)

Environment

None

Status

Assignee

Unassigned

Reporter

Ghadi Shayban

Labels

Approval

Vetted

Patch

None

Affects versions

Release 1.8
Release 1.7

Priority

Major