Uploaded image for project: 'Clojure'
  1. CLJ-1879

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

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: Release 1.7, Release 1.8
    • Fix versions: None
    • Labels:
    • Approval:
      Vetted

      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)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gshayban Ghadi Shayban
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: