From 695b40293481735a2a124ae62bdd1ca5b0599523 Mon Sep 17 00:00:00 2001 From: tjjfvi Date: Mon, 25 Mar 2024 09:06:49 -0400 Subject: [PATCH] tweaks --- src/run/linker.rs | 9 ++++----- src/run/parallel.rs | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/run/linker.rs b/src/run/linker.rs index 31d67b26..82b1091a 100644 --- a/src/run/linker.rs +++ b/src/run/linker.rs @@ -371,8 +371,8 @@ impl RedexQueue { self.fast.is_empty() && self.slow.is_empty() } #[inline(always)] - pub fn take(&mut self) -> impl Iterator { - std::mem::take(&mut self.fast).into_iter().chain(std::mem::take(&mut self.slow)) + pub fn drain(&mut self) -> impl Iterator + '_ { + self.fast.drain(..).chain(self.slow.drain(..)) } #[inline(always)] pub fn iter(&self) -> impl Iterator { @@ -392,7 +392,6 @@ impl RedexQueue { // Returns whether a redex does not allocate memory fn redex_would_shrink(a: &Port, b: &Port) -> bool { (*a == Port::ERA || *b == Port::ERA) - || (!(a.tag() == Tag::Ref || b.tag() == Tag::Ref) - && (((a.tag() == Tag::Ctr && b.tag() == Tag::Ctr) || a.lab() == b.lab()) - || (a.tag() == Tag::Num || b.tag() == Tag::Num))) + || (a.tag() == Tag::Ctr && b.tag() == Tag::Ctr && a.lab() == b.lab()) + || (!(a.tag() == Tag::Ref || b.tag() == Tag::Ref) && (a.tag() == Tag::Num || b.tag() == Tag::Num)) } diff --git a/src/run/parallel.rs b/src/run/parallel.rs index aec41c3d..d20bd478 100644 --- a/src/run/parallel.rs +++ b/src/run/parallel.rs @@ -4,7 +4,7 @@ impl<'h, M: Mode> Net<'h, M> { /// Forks the net into `tids` child nets, for parallel operation. pub fn fork(&mut self, tids: usize) -> impl Iterator + '_ { let redexes_len = self.redexes.len(); - let mut redexes = self.redexes.take(); + let mut redexes = self.redexes.drain(); (0 .. tids).map(move |tid| { let heap_size = (self.heap.0.len() / tids) & !63; // round down to needed alignment let heap_start = heap_size * tid; @@ -71,7 +71,6 @@ impl<'h, M: Mode> Net<'h, M> { } }); - // Clear redexes and sum stats delta.add_to(&mut self.rwts); // Main reduction loop