Skip to content

Commit d2e939f

Browse files
Added a comment re possible further optimization
1 parent c7c52a5 commit d2e939f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/seq/increasing_uniform.rs

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ impl<R: RngCore> IncreasingUniform<R> {
3232
pub fn next_index(&mut self) -> usize {
3333
let next_n = self.n + 1;
3434

35+
// There's room for further optimisation here:
36+
// gen_range uses rejection sampling (or other method; see #1196) to avoid bias.
37+
// When the initial sample is biased for range 0..bound
38+
// it may still be viable to use for a smaller bound
39+
// (especially if small biases are considered acceptable).
40+
3541
let next_chunk_remaining = self.chunk_remaining.checked_sub(1).unwrap_or_else(|| {
3642
// If the chunk is empty, generate a new chunk
3743
let (bound, remaining) = calculate_bound_u32(next_n);

0 commit comments

Comments
 (0)