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

Use PAM for small maps when assigned to a var rather than always using PHMs

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Declined
    • Affects versions: None
    • Fix versions: None
    • Patch:
      Code

      Description

      I'm reproposing the fix I implemented for http://dev.clojure.org/jira/browse/CLJ-944 a while ago as an enhancement rather than as a defect.

      Currently when a map is used as the value of a `def` expression, unless it's an empty map, it will always be a PersistentHashMap even if it's a small map.

      user=> (def a {:foo :bar})
      #'user/a
      user=> (class a)
      clojure.lang.PersistentHashMap
      

      The current patch makes makes small maps be compiled to PAMs, consistently with how it's handled in lexical contexts, only using PHMs when the number of elements is above the threshold

      user=> (def a {:foo :bar})
      #'user/a
      user=> (class a)
      clojure.lang.PersistentArrayMap
      user=> (class (let [a {:foo :bar}] a))
      clojure.lang.PersistentArrayMap
      user=> (def a {0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9})
      #'user/a
      user=> (class a)
      clojure.lang.PersistentHashMap
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bronsa Nicola Mometto
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: