Skip to content

Commit 2531aac

Browse files
committed
Remove Rand.Get()
1 parent 880dc27 commit 2531aac

File tree

2 files changed

+0
-37
lines changed

2 files changed

+0
-37
lines changed

rand.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,6 @@ func (r *Rand) new_(seed ...uint64) {
8181
}
8282
}
8383

84-
// Get returns r, initializing it as if it was constructed by [New] if it was previously uninitialized.
85-
// This allows to conveniently use Rand values non-deterministically without explicit initialization:
86-
//
87-
// type Dice struct {
88-
// rng rand.Rand
89-
// }
90-
//
91-
// func (d *Dice) Roll() int {
92-
// return d.rng.Get().Intn(6)
93-
// }
94-
func (r *Rand) Get() *Rand {
95-
if r.w == 0 && *r == zero {
96-
r.init0()
97-
}
98-
return r
99-
}
100-
10184
// Seed uses the provided seed value to initialize the generator to a deterministic state.
10285
func (r *Rand) Seed(seed uint64) {
10386
r.init1(seed)

rand_bench_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -283,26 +283,6 @@ func BenchmarkRand_NewInt(b *testing.B) {
283283
sinkInt = s
284284
}
285285

286-
func BenchmarkRand_Get(b *testing.B) {
287-
var r rand.Rand
288-
var s *rand.Rand
289-
b.ReportAllocs()
290-
for i := 0; i < b.N; i++ {
291-
s = r.Get()
292-
}
293-
sinkRand = s
294-
}
295-
296-
func BenchmarkRand_GetInt(b *testing.B) {
297-
var r rand.Rand
298-
var s int
299-
b.ReportAllocs()
300-
for i := 0; i < b.N; i++ {
301-
s = r.Get().Int()
302-
}
303-
sinkInt = s
304-
}
305-
306286
func BenchmarkRand_ExpFloat64(b *testing.B) {
307287
var s float64
308288
r := rand.New(1)

0 commit comments

Comments
 (0)