Skip to content

Commit 50f2c29

Browse files
committed
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`
2 parents 3b65165 + 73f5b65 commit 50f2c29

File tree

1 file changed

+14
-1
lines changed
  • compiler/rustc_const_eval/src/transform/check_consts

1 file changed

+14
-1
lines changed

compiler/rustc_const_eval/src/transform/check_consts/resolver.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ where
264264
}
265265
}
266266

267-
#[derive(Clone, Debug, PartialEq, Eq)]
267+
#[derive(Debug, PartialEq, Eq)]
268268
pub(super) struct State {
269269
/// Describes whether a local contains qualif.
270270
pub qualif: BitSet<Local>,
@@ -273,6 +273,19 @@ pub(super) struct State {
273273
pub borrow: BitSet<Local>,
274274
}
275275

276+
impl Clone for State {
277+
fn clone(&self) -> Self {
278+
State { qualif: self.qualif.clone(), borrow: self.borrow.clone() }
279+
}
280+
281+
// Data flow engine when possible uses `clone_from` for domain values.
282+
// Providing an implementation will avoid some intermediate memory allocations.
283+
fn clone_from(&mut self, other: &Self) {
284+
self.qualif.clone_from(&other.qualif);
285+
self.borrow.clone_from(&other.borrow);
286+
}
287+
}
288+
276289
impl State {
277290
#[inline]
278291
pub(super) fn contains(&self, local: Local) -> bool {

0 commit comments

Comments
 (0)