testutil, storage: use math/rand.Read where possible
Use the much faster math/rand.Read function where cryptographic guarantees are not required. The unit test suite should speed up a little bit but we've already optimized around this, so it may not matter. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
bfa0a9c097
commit
040db51795
3 changed files with 3 additions and 8 deletions
|
@ -3,7 +3,6 @@ package testutil
|
|||
import (
|
||||
"archive/tar"
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"io"
|
||||
mrand "math/rand"
|
||||
|
@ -46,7 +45,7 @@ func CreateRandomTarFile() (rs io.ReadSeeker, dgst digest.Digest, err error) {
|
|||
randomData := make([]byte, fileSize)
|
||||
|
||||
// Fill up the buffer with some random data.
|
||||
n, err := rand.Read(randomData)
|
||||
n, err := mrand.Read(randomData)
|
||||
|
||||
if n != len(randomData) {
|
||||
return nil, "", fmt.Errorf("short read creating random reader: %v bytes != %v bytes", n, len(randomData))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue