Implement clone_from for State

Data flow engine uses `clone_from` for domain values.  Providing an
implementation of `clone_from` will avoid some intermediate memory
allocations.
This commit is contained in:
Tomasz Miąsko 2021-11-03 00:00:00 +00:00
parent 473eaa42e9
commit 73f5b65818

View File

@ -256,7 +256,7 @@ where
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq)]
pub(super) struct State {
/// Describes whether a local contains qualif.
pub qualif: BitSet<Local>,
@ -265,6 +265,19 @@ pub(super) struct State {
pub borrow: BitSet<Local>,
}
impl Clone for State {
fn clone(&self) -> Self {
State { qualif: self.qualif.clone(), borrow: self.borrow.clone() }
}
// Data flow engine when possible uses `clone_from` for domain values.
// Providing an implementation will avoid some intermediate memory allocations.
fn clone_from(&mut self, other: &Self) {
self.qualif.clone_from(&other.qualif);
self.borrow.clone_from(&other.borrow);
}
}
impl State {
#[inline]
pub(super) fn contains(&self, local: Local) -> bool {