Prefer clone_from over assign

This commit is contained in:
2021-07-15 17:25:30 +02:00
parent e4ea5b081b
commit e25ee9c74a
6 changed files with 38 additions and 35 deletions

View File

@@ -38,8 +38,7 @@ impl OutputThread {
match self.rx.as_ref().unwrap().try_recv() {
Ok(mut copy_fields) => {
for (from, to) in fields.iter().zip(copy_fields.iter_mut()) {
use integrate::Integrable;
euler::Field::assign(to, from);
to.clone_from(&from);
}
self.tx
.as_ref()

View File

@@ -30,17 +30,7 @@ pub(crate) static MULTITHREAD: AtomicBool = AtomicBool::new(false);
impl integrate::Integrable for System {
type State = Vec<euler::Field>;
type Diff = Vec<euler::Diff>;
fn assign(s: &mut Self::State, o: &Self::State) {
if MULTITHREAD.load(Ordering::Acquire) {
s.par_iter_mut()
.zip(o.par_iter())
.for_each(|(s, o)| euler::Field::assign(s, o))
} else {
s.iter_mut()
.zip(o.iter())
.for_each(|(s, o)| euler::Field::assign(s, o))
}
}
fn scaled_add(s: &mut Self::State, o: &Self::Diff, scale: Float) {
if MULTITHREAD.load(Ordering::Acquire) {
s.par_iter_mut()