From 68b90af75547ab1f89a3c2f0fdfaf9889b7bbb9b Mon Sep 17 00:00:00 2001 From: Breval Ferrari Date: Mon, 10 Mar 2025 00:31:05 -0400 Subject: [PATCH] improve rayon on bytes --- bingus/src/bin_/bytes.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bingus/src/bin_/bytes.rs b/bingus/src/bin_/bytes.rs index c1498f2..c286c06 100644 --- a/bingus/src/bin_/bytes.rs +++ b/bingus/src/bin_/bytes.rs @@ -1,6 +1,6 @@ use std::convert::Infallible; -use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; use crate::{Bendable, Bytes, IntoDataBytes, TryFromDataBytes}; @@ -23,8 +23,9 @@ impl TryFromDataBytes for Bytes { impl Bendable for Bytes { type Unit = u8; - fn map Self::Unit + Sync>(self, f: F) -> Self { - self.into_par_iter().map(|e| f(&e)).collect() + fn map Self::Unit + Sync>(mut self, f: F) -> Self { + self.par_iter_mut().for_each(|e| *e = f(e)); + self } fn format() -> crate::Format { crate::Format::Binary