Skip to content

Commit

Permalink
randstring: simpler implementation, default to 8 characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Jan 28, 2013
1 parent bda9432 commit 399c541
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,8 @@ memchr(a::Array{Uint8,1}, b) = memchr(a,b,1)

# return a random string (often useful for temporary filenames/dirnames)
let
global randstring
const randstring_chars = ASCIIString(uint8([0x30:0x39,0x41:0x5a,0x61:0x7a]))
randstring(len::Int) =
randstring_chars[iceil(length(randstring_chars)*rand(len))]
global randstring
const b = uint8(['0':'9','A':'Z','a':'z'])
randstring(n::Int) = ASCIIString(b[rand(1:length(b),n)])
randstring() = randstring(8)
end

0 comments on commit 399c541

Please sign in to comment.