Skip to content

Commit

Permalink
Auto merge of rust-lang#90535 - tmiasko:clone-from, r=oli-obk
Browse files Browse the repository at this point in the history
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 rust-lang#90413.

r? `@oli-obk`
  • Loading branch information
bors committed Nov 20, 2021
2 parents 3b65165 + 73f5b65 commit 50f2c29
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion compiler/rustc_const_eval/src/transform/check_consts/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -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 {
Expand Down

0 comments on commit 50f2c29

Please sign in to comment.