Skip to content

Commit 6504ae0

Browse files
fix(netwatch): non-allocating prefixes_major_equal
1 parent da22bc8 commit 6504ae0

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

netwatch/src/interfaces.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,16 @@ fn prefixes_major_equal(a: impl Iterator<Item = IpNet>, b: impl Iterator<Item =
427427
true
428428
}
429429

430-
let a: Vec<_> = a.filter(is_interesting).collect();
431-
let b: Vec<_> = b.filter(is_interesting).collect();
432-
433-
a == b
430+
let mut a = a.filter(is_interesting);
431+
let mut b = b.filter(is_interesting);
432+
433+
loop {
434+
match (a.next(), b.next()) {
435+
(None, None) => return true,
436+
(Some(a), Some(b)) if a == b => continue,
437+
_ => return false,
438+
}
439+
}
434440
}
435441

436442
#[cfg(test)]

0 commit comments

Comments
 (0)