@@ -12371,9 +12371,9 @@ reduces them without incurring seq initialization"
12371
12371
(let [a (hash a)
12372
12372
b (hash b)]
12373
12373
(cond
12374
- (< a b) -1
12375
- (> a b) 1
12376
- :else 0 )))
12374
+ (< a b) -1
12375
+ (> a b) 1
12376
+ :else 0 )))
12377
12377
12378
12378
(defn- obj-clone [obj ks]
12379
12379
(let [new-obj (js-obj )
@@ -12387,6 +12387,10 @@ reduces them without incurring seq initialization"
12387
12387
12388
12388
(declare simple-hash-map )
12389
12389
12390
+ (defn- keyword->obj-map-key
12391
+ [k]
12392
+ (str " \u FDD0" " '" (. k -fqn)))
12393
+
12390
12394
(deftype ObjMap [meta keys strobj ^:mutable __hash]
12391
12395
IWithMeta
12392
12396
(-with-meta [coll meta] (ObjMap. meta keys strobj __hash))
@@ -12422,41 +12426,45 @@ reduces them without incurring seq initialization"
12422
12426
ILookup
12423
12427
(-lookup [coll k] (-lookup coll k nil ))
12424
12428
(-lookup [coll k not-found]
12425
- (if (and (string? k)
12426
- (not (nil? (scan-array 1 k keys))))
12427
- (unchecked-get strobj k)
12428
- not-found))
12429
+ (let [k (if-not (keyword? k) k (keyword->obj-map-key k))]
12430
+ (if (and (string? k)
12431
+ (not (nil? (scan-array 1 k keys))))
12432
+ (unchecked-get strobj k)
12433
+ not-found)))
12429
12434
12430
12435
IAssociative
12431
12436
(-assoc [coll k v]
12432
- (if (string? k)
12433
- (if-not (nil? (scan-array 1 k keys))
12434
- (let [new-strobj (obj-clone strobj keys)]
12435
- (gobject/set new-strobj k v)
12436
- (ObjMap. meta keys new-strobj nil )) ; overwrite
12437
- (let [new-strobj (obj-clone strobj keys) ; append
12438
- new-keys (aclone keys)]
12439
- (gobject/set new-strobj k v)
12440
- (.push new-keys k)
12441
- (ObjMap. meta new-keys new-strobj nil )))
12442
- ; non-string key. game over.
12443
- (-with-meta
12444
- (-kv-reduce coll
12445
- (fn [ret k v]
12446
- (-assoc ret k v))
12447
- (. HashMap -EMPTY) )
12448
- meta)))
12437
+ (let [k (if-not (keyword? k) k (keyword->obj-map-key k))]
12438
+ (if (string? k)
12439
+ (if-not (nil? (scan-array 1 k keys))
12440
+ (let [new-strobj (obj-clone strobj keys)]
12441
+ (gobject/set new-strobj k v)
12442
+ (ObjMap. meta keys new-strobj nil )) ; overwrite
12443
+ (let [new-strobj (obj-clone strobj keys) ; append
12444
+ new-keys (aclone keys)]
12445
+ (gobject/set new-strobj k v)
12446
+ (.push new-keys k)
12447
+ (ObjMap. meta new-keys new-strobj nil )))
12448
+ ; non-string key. game over.
12449
+ (-with-meta
12450
+ (-kv-reduce coll
12451
+ (fn [ret k v]
12452
+ (-assoc ret k v))
12453
+ (. HashMap -EMPTY))
12454
+ meta))))
12449
12455
(-contains-key? [coll k]
12450
- (if (and (string? k)
12451
- (not (nil? (scan-array 1 k keys))))
12452
- true
12453
- false ))
12456
+ (let [k (if-not (keyword? k) k (keyword->obj-map-key k))]
12457
+ (if (and (string? k)
12458
+ (not (nil? (scan-array 1 k keys))))
12459
+ true
12460
+ false )))
12454
12461
12455
12462
IFind
12456
12463
(-find [coll k]
12457
- (when (and (string? k)
12458
- (not (nil? (scan-array 1 k keys))))
12459
- (MapEntry. k (unchecked-get strobj k) nil )))
12464
+ (let [k (if-not (keyword? k) k (keyword->obj-map-key k))]
12465
+ (when (and (string? k)
12466
+ (not (nil? (scan-array 1 k keys))))
12467
+ (MapEntry. k (unchecked-get strobj k) nil ))))
12460
12468
12461
12469
IKVReduce
12462
12470
(-kv-reduce [coll f init]
@@ -12473,14 +12481,15 @@ reduces them without incurring seq initialization"
12473
12481
12474
12482
IMap
12475
12483
(-dissoc [coll k]
12476
- (if (and (string? k)
12477
- (not (nil? (scan-array 1 k keys))))
12478
- (let [new-keys (aclone keys)
12479
- new-strobj (obj-clone strobj keys)]
12480
- (.splice new-keys (scan-array 1 k new-keys) 1 )
12481
- (js-delete new-strobj k)
12482
- (ObjMap. meta new-keys new-strobj nil ))
12483
- coll)) ; key not found, return coll unchanged
12484
+ (let [k (if-not (keyword? k) k (keyword->obj-map-key k))]
12485
+ (if (and (string? k)
12486
+ (not (nil? (scan-array 1 k keys))))
12487
+ (let [new-keys (aclone keys)
12488
+ new-strobj (obj-clone strobj keys)]
12489
+ (.splice new-keys (scan-array 1 k new-keys) 1 )
12490
+ (js-delete new-strobj k)
12491
+ (ObjMap. meta new-keys new-strobj nil ))
12492
+ coll))) ; key not found, return coll unchanged
12484
12493
12485
12494
IFn
12486
12495
(-invoke [coll k]
0 commit comments