mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
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:
commit
50f2c29200
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user