Merge pull request #1997 from dzamlo/main

stm32: avoid useless endian conversion in rng
This commit is contained in:
Dario Nieuwenhuis 2023-10-02 15:31:13 +00:00 committed by GitHub
commit ce0add61f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -164,7 +164,7 @@ impl<'d, T: Instance> Rng<'d, T> {
return Err(Error::SeedError);
}
// write bytes to chunk
for (dest, src) in chunk.iter_mut().zip(random_word.to_be_bytes().iter()) {
for (dest, src) in chunk.iter_mut().zip(random_word.to_ne_bytes().iter()) {
*dest = *src
}
}
@ -195,7 +195,7 @@ impl<'d, T: Instance> RngCore for Rng<'d, T> {
fn fill_bytes(&mut self, dest: &mut [u8]) {
for chunk in dest.chunks_mut(4) {
let rand = self.next_u32();
for (slot, num) in chunk.iter_mut().zip(rand.to_be_bytes().iter()) {
for (slot, num) in chunk.iter_mut().zip(rand.to_ne_bytes().iter()) {
*slot = *num
}
}