File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 321321 (unpack [ba]
322322 (CachedKey. (get @c/*key-cache_* (bit-and 0xff (aget ^bytes ba 0 ))))))
323323
324+ (c/extend-packable 9 java.util.UUID
325+ (pack [u] (.getBytes (str u) StandardCharsets/UTF_8))
326+ (unpack [ba] (java.util.UUID/fromString (String. ^bytes ba StandardCharsets/UTF_8))))
327+
328+ #_ ; Unfortunately no simple equivalent for Cljs
329+ (c/extend-packable 9 java.util.UUID
330+ (pack [u]
331+ (with-out [out 64 ]
332+ (.writeLong out (.getMostSignificantBits u))
333+ (.writeLong out (.getLeastSignificantBits u))))
334+
335+ (unpack [ba] (with-in [in ba] (java.util.UUID. (.readLong in) (.readLong in)))))
336+
337+ (comment (unpack (pack (java.util.UUID/randomUUID ))))
338+
324339; ;;;
325340
326341(defn pack
Original file line number Diff line number Diff line change 452452 (unpack [u8s]
453453 (CachedKey. (get @c/*key-cache_* (aget ^js u8s 0 )))))
454454
455+ (c/extend-packable 9 UUID
456+ (pack [u] (.encode text-encoder (str u)))
457+ (unpack [^js u8s] (uuid (.decode text-decoder ^js u8s))))
458+
455459; ;;;
456460
457461(defn unpack [in] (unpack-1 (in-stream* in)))
Original file line number Diff line number Diff line change 118118 #?(:clj (is (rt? " Timestamps" (java.time.Instant/now ) (java.util.Date. ) (java.util.Date. -1 ))))
119119 #?(:cljs (is (rt? " Timestamps" (js/Date. ))))
120120
121+ (rt? " UUID" #uuid " 66d96ab4-9834-40db-a3cd-42b361503ab9" )
122+
121123 (testing " Key caching"
122124 [(rt? " Basic" [{:a :A } {:a :A }] {:foo {1 {:x :X } 2 {:y :Y }}})
123125 (rt? " >256 keys" (let [m (into {} (map (fn [n] [(str " key" n) n])) (range 512 ))] [m m {:a :A :b :B } m]))
You can’t perform that action at this time.
0 commit comments