Skip to content

Commit

Permalink
Generate larger range of random UUIDs
Browse files Browse the repository at this point in the history
The random-uuid function was only generating hex characters from 0-e,
but should be using 0-f.

Adjusted the arg to the first rand-int call to make this work, and
adjusted the second one as well, which should have no effect on the
behavior but is less confusing to read.
  • Loading branch information
gfredericks authored and dnolen committed Nov 4, 2015
1 parent 6dc027b commit 2a8e17f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9861,8 +9861,8 @@ Maps become Objects. Arbitrary keys are encoded to by key->js."
(UUID. s nil))

(defn random-uuid []
(letfn [(hex [] (.toString (rand-int 15) 16))]
(let [rhex (.toString (bit-or 0x8 (bit-and 0x3 (rand-int 14))) 16)]
(letfn [(hex [] (.toString (rand-int 16) 16))]
(let [rhex (.toString (bit-or 0x8 (bit-and 0x3 (rand-int 16))) 16)]
(uuid
(str (hex) (hex) (hex) (hex)
(hex) (hex) (hex) (hex) "-"
Expand Down

0 comments on commit 2a8e17f

Please sign in to comment.