Skip to content

Commit 93ade1a

Browse files
committed
fill_via_chunks: better value names
1 parent 9972046 commit 93ade1a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

rand_core/src/impls.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,22 @@ impl ToLe for u64 {
7171

7272
fn fill_via_chunks<T: ToLe>(src: &[T], dest: &mut [u8]) -> (usize, usize) {
7373
let size = core::mem::size_of::<T>();
74-
let chunk_size_u8 = min(src.len() * size, dest.len());
75-
let chunk_size = (chunk_size_u8 + size - 1) / size;
74+
let byte_len = min(src.len() * size, dest.len());
75+
let num_chunks = (byte_len + size - 1) / size;
7676

7777
if cfg!(target_endian = "little") {
7878
// On LE we can do a simple copy, which is 25-50% faster:
7979
unsafe {
8080
core::ptr::copy_nonoverlapping(
8181
src.as_ptr() as *const u8,
8282
dest.as_mut_ptr(),
83-
chunk_size_u8,
83+
byte_len,
8484
);
8585
}
8686
} else {
8787
// This code is valid on all arches, but slower than the above:
8888
let mut i = 0;
89-
let mut iter = dest[..chunk_size_u8].chunks_exact_mut(size);
89+
let mut iter = dest[..byte_len].chunks_exact_mut(size);
9090
while let Some(chunk) = iter.next() {
9191
chunk.copy_from_slice(src[i].to_le_bytes().as_ref());
9292
i += 1;
@@ -97,7 +97,7 @@ fn fill_via_chunks<T: ToLe>(src: &[T], dest: &mut [u8]) -> (usize, usize) {
9797
}
9898
}
9999

100-
(chunk_size, chunk_size_u8)
100+
(num_chunks, byte_len)
101101
}
102102

103103
/// Implement `fill_bytes` by reading chunks from the output buffer of a block

0 commit comments

Comments
 (0)