improve rayon on bytes
This commit is contained in:
parent
7ca053d918
commit
68b90af755
1 changed files with 4 additions and 3 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue