From 1d1043316bfa326ed385e6b0e48d726395afb817 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Fri, 2 Dec 2022 14:53:23 +0100 Subject: [PATCH] vm-migration: Don't store snapshots through a Box Signed-off-by: Sebastien Boeuf --- vm-migration/src/lib.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vm-migration/src/lib.rs b/vm-migration/src/lib.rs index 20a3fe0c5..56509b2bb 100644 --- a/vm-migration/src/lib.rs +++ b/vm-migration/src/lib.rs @@ -147,7 +147,7 @@ pub struct Snapshot { pub id: String, /// The Snapshottable component snapshots. - pub snapshots: std::collections::BTreeMap>, + pub snapshots: std::collections::BTreeMap, /// The Snapshottable component's snapshot data. /// A map of snapshot sections, indexed by the section ids. @@ -187,8 +187,7 @@ impl Snapshot { /// Add a sub-component's Snapshot to the Snapshot. pub fn add_snapshot(&mut self, snapshot: Snapshot) { - self.snapshots - .insert(snapshot.id.clone(), Box::new(snapshot)); + self.snapshots.insert(snapshot.id.clone(), snapshot); } /// Add a SnapshotData to the component snapshot data. @@ -220,7 +219,7 @@ impl Snapshot { } pub fn snapshot_from_id(snapshot: Option<&Snapshot>, id: &str) -> Option { - snapshot.and_then(|s| s.snapshots.get(id).map(|s| *s.clone())) + snapshot.and_then(|s| s.snapshots.get(id).cloned()) } pub fn versioned_state_from_id( @@ -231,7 +230,7 @@ where T: Versionize + VersionMapped, { snapshot - .and_then(|s| s.snapshots.get(id).map(|s| *s.clone())) + .and_then(|s| s.snapshots.get(id).cloned()) .map(|s| s.to_versioned_state()) .transpose() }