Skip to content

Commit 73f5b65

Browse files
committed
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.
1 parent 473eaa4 commit 73f5b65

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
@@ -256,7 +256,7 @@ where
256256
}
257257
}
258258

259-
#[derive(Clone, Debug, PartialEq, Eq)]
259+
#[derive(Debug, PartialEq, Eq)]
260260
pub(super) struct State {
261261
/// Describes whether a local contains qualif.
262262
pub qualif: BitSet<Local>,
@@ -265,6 +265,19 @@ pub(super) struct State {
265265
pub borrow: BitSet<Local>,
266266
}
267267

268+
impl Clone for State {
269+
fn clone(&self) -> Self {
270+
State { qualif: self.qualif.clone(), borrow: self.borrow.clone() }
271+
}
272+
273+
// Data flow engine when possible uses `clone_from` for domain values.
274+
// Providing an implementation will avoid some intermediate memory allocations.
275+
fn clone_from(&mut self, other: &Self) {
276+
self.qualif.clone_from(&other.qualif);
277+
self.borrow.clone_from(&other.borrow);
278+
}
279+
}
280+
268281
impl State {
269282
#[inline]
270283
pub(super) fn contains(&self, local: Local) -> bool {

0 commit comments

Comments
 (0)