Skip to content

Commit 4370fd8

Browse files
committed
sim-rs: avoid copying massive map of arcs
1 parent cba52df commit 4370fd8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

sim-rs/sim-core/src/events.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<Node: Display> Serialize for Votes<Node> {
289289
pub struct EventTracker {
290290
sender: mpsc::UnboundedSender<(Event, Timestamp)>,
291291
clock: Clock,
292-
node_names: BTreeMap<NodeId, Arc<String>>,
292+
node_names: Arc<BTreeMap<NodeId, Arc<String>>>,
293293
}
294294

295295
impl EventTracker {
@@ -298,10 +298,12 @@ impl EventTracker {
298298
clock: Clock,
299299
nodes: &[NodeConfiguration],
300300
) -> Self {
301-
let node_names = nodes
302-
.iter()
303-
.map(|n| (n.id, Arc::new(n.name.clone())))
304-
.collect();
301+
let node_names = Arc::new(
302+
nodes
303+
.iter()
304+
.map(|n| (n.id, Arc::new(n.name.clone())))
305+
.collect(),
306+
);
305307
Self {
306308
sender,
307309
clock,

0 commit comments

Comments
 (0)