Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi committed Mar 25, 2024
1 parent de3d1fc commit 695b402
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/run/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ impl RedexQueue {
self.fast.is_empty() && self.slow.is_empty()
}
#[inline(always)]
pub fn take(&mut self) -> impl Iterator<Item = (Port, Port)> {
std::mem::take(&mut self.fast).into_iter().chain(std::mem::take(&mut self.slow))
pub fn drain(&mut self) -> impl Iterator<Item = (Port, Port)> + '_ {
self.fast.drain(..).chain(self.slow.drain(..))
}
#[inline(always)]
pub fn iter(&self) -> impl Iterator<Item = &(Port, Port)> {
Expand All @@ -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))
}
3 changes: 1 addition & 2 deletions src/run/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = Self> + '_ {
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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 695b402

Please sign in to comment.