mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-19 10:24:16 +00:00
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:
parent
473eaa42e9
commit
73f5b65818
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user