improve rayon on bytes

This commit is contained in:
Breval Ferrari 2025-03-10 00:31:05 -04:00
parent 7ca053d918
commit 68b90af755
No known key found for this signature in database
GPG key ID: F71E304D6400AB8E

View file

@ -1,6 +1,6 @@
use std::convert::Infallible; use std::convert::Infallible;
use rayon::iter::{IntoParallelIterator, ParallelIterator}; use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
use crate::{Bendable, Bytes, IntoDataBytes, TryFromDataBytes}; use crate::{Bendable, Bytes, IntoDataBytes, TryFromDataBytes};
@ -23,8 +23,9 @@ impl TryFromDataBytes for Bytes {
impl Bendable for Bytes { impl Bendable for Bytes {
type Unit = u8; type Unit = u8;
fn map<F: Fn(&Self::Unit) -> Self::Unit + Sync>(self, f: F) -> Self { fn map<F: Fn(&Self::Unit) -> Self::Unit + Sync>(mut self, f: F) -> Self {
self.into_par_iter().map(|e| f(&e)).collect() self.par_iter_mut().for_each(|e| *e = f(e));
self
} }
fn format() -> crate::Format { fn format() -> crate::Format {
crate::Format::Binary crate::Format::Binary