mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 11:21:10 +08:00
fs: update use of math/rand to modern practice
This commit is contained in:
parent
7aa066cff8
commit
208e49ce4b
|
@ -1,10 +1,10 @@
|
||||||
package quickxorhash
|
package quickxorhash
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash"
|
"hash"
|
||||||
"math/rand"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -171,7 +171,9 @@ var _ hash.Hash = (*quickXorHash)(nil)
|
||||||
func BenchmarkQuickXorHash(b *testing.B) {
|
func BenchmarkQuickXorHash(b *testing.B) {
|
||||||
b.SetBytes(1 << 20)
|
b.SetBytes(1 << 20)
|
||||||
buf := make([]byte, 1<<20)
|
buf := make([]byte, 1<<20)
|
||||||
rand.Read(buf)
|
n, err := rand.Read(buf)
|
||||||
|
require.NoError(b, err)
|
||||||
|
require.Equal(b, len(buf), n)
|
||||||
h := New()
|
h := New()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -52,8 +51,7 @@ var (
|
||||||
|
|
||||||
// Seed the random number generator
|
// Seed the random number generator
|
||||||
func init() {
|
func init() {
|
||||||
rand.Seed(time.Now().UnixNano())
|
_ = random.Seed()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise rclone for testing
|
// Initialise rclone for testing
|
||||||
|
|
|
@ -31,7 +31,7 @@ var (
|
||||||
|
|
||||||
// Seed the random number generator
|
// Seed the random number generator
|
||||||
func init() {
|
func init() {
|
||||||
rand.Seed(time.Now().UnixNano())
|
_ = random.Seed()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user