File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -273,10 +273,13 @@ nil if the end of stream has been reached")
273
273
274
274
(defn read-map
275
275
[rdr _]
276
- (let [l (read-delimited-list " }" rdr true )]
277
- (when (odd? (count l))
276
+ (let [l (read-delimited-list " }" rdr true )
277
+ c (count l)]
278
+ (when (odd? c)
278
279
(reader-error rdr " Map literal must contain an even number of forms" ))
279
- (apply hash-map l)))
280
+ (if (<= c (* 2 (.-HASHMAP-THRESHOLD PersistentArrayMap)))
281
+ (apply array-map l)
282
+ (apply hash-map l))))
280
283
281
284
(defn read-number
282
285
[reader initch]
Original file line number Diff line number Diff line change 174
174
(testing " Testing reading, CLJS-819"
175
175
(is (= m " \u 00a1" )))))
176
176
177
+ (deftest testing-map-type
178
+ (let [a (reader/read-string " {:a 1 :b 2 :c 3}" )
179
+ b (reader/read-string " {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9}" )]
180
+ (is (= a {:a 1 :b 2 :c 3 }))
181
+ (is (instance? PersistentArrayMap a))
182
+ (is (= b {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9 }))
183
+ (is (instance? PersistentHashMap b))))
184
+
177
185
; ; NOTE: issue uncovered by test.check
178
186
179
187
(deftest test-slash-reading
You can’t perform that action at this time.
0 commit comments