From 87c54b9ba5a02ac5745160d06820ae9094db7b6f Mon Sep 17 00:00:00 2001 From: Dmitry Chestnykh Date: Wed, 21 Jan 2015 21:40:45 +0100 Subject: [PATCH] Move allocations later in the function. --- uniuri.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uniuri.go b/uniuri.go index 1852b81..2063037 100644 --- a/uniuri.go +++ b/uniuri.go @@ -53,13 +53,13 @@ func NewLenChars(length int, chars []byte) string { if length == 0 { return "" } - b := make([]byte, length) - r := make([]byte, length+(length/4)) // storage for random bytes. clen := len(chars) if clen > 256 { panic("uniuri: maximum length of charset for NewLenChars is 256") } maxrb := 256 - (256 % clen) + b := make([]byte, length) + r := make([]byte, length+(length/4)) // storage for random bytes. i := 0 for { if _, err := rand.Read(r); err != nil {