Auto merge of #90535 - tmiasko:clone-from, r=oli-obk

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.

Extracted from #90413.

r? `@oli-obk`
This commit is contained in:
bors 2021-11-20 04:12:03 +00:00
commit 50f2c29200

View File

@ -264,7 +264,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>,
@ -273,6 +273,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 {