]> Cypherpunks repositories - gostls13.git/commit
rand: add explicit Int31n to avoid 64-bit divide on 32-bit machines
authorRuss Cox <rsc@golang.org>
Wed, 16 Dec 2009 01:21:34 +0000 (17:21 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 16 Dec 2009 01:21:34 +0000 (17:21 -0800)
commitf64bb56bae3029ab2491bd40634284677ab191e5
treef846db7bcaeab16efd356a2ffca01173071f2521
parent1e9e7ec4b3e4c7bb9b014398ea07b7c3f3ae0f21
rand: add explicit Int31n to avoid 64-bit divide on 32-bit machines
    use Int31n in Intn when possible.

Fixes #390.

(using 8g)
Intn1000      50000000         38 ns/op
Int31n1000    50000000         39 ns/op
Int63n1000    20000000        114 ns/op

R=r
CC=golang-dev, skybrian
https://golang.org/cl/180054
src/pkg/rand/rand.go
src/pkg/rand/rand_test.go