Skip to content

Commit 7f61e2f

Browse files
committed
Use fill_bytes_via_u32 in JitterRng
1 parent 7a07c36 commit 7f61e2f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/jitter.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,13 @@ impl Rng for JitterRng {
738738
}
739739

740740
fn fill_bytes(&mut self, dest: &mut [u8]) {
741-
impls::fill_bytes_via_u64(self, dest)
741+
// Fill using `next_u32`. This is faster for filling small slices (four
742+
// bytes or less), while the overhead is negligible (in benchmarks even
743+
// slightly faster instead of slower).
744+
//
745+
// This is done especially for wrappers that implement `next_u32`
746+
// themselves via `fill_bytes`.
747+
impls::fill_bytes_via_u32(self, dest)
742748
}
743749
}
744750

0 commit comments

Comments
 (0)