From 815fd19a33fa5226b7d1a369bb8c93cda78abd55 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 31 Aug 2021 20:40:36 +0200 Subject: [PATCH] state-res: Remove pointless shifting around of Vec elements --- crates/ruma-state-res/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ruma-state-res/src/lib.rs b/crates/ruma-state-res/src/lib.rs index 1fa22980..60b92961 100644 --- a/crates/ruma-state-res/src/lib.rs +++ b/crates/ruma-state-res/src/lib.rs @@ -192,7 +192,10 @@ impl StateResolution { state_sets.iter().map(|state_set| state_set.get(key)).collect::>(); if event_ids.iter().all_equal() { - let id = event_ids.remove(0).expect("unconflicting `EventId` is not None"); + // First .unwrap() is okay because + // * event_ids has the same length as state_sets + // * we never enter the loop this code is in if state_sets is empty + let id = event_ids.pop().unwrap().expect("unconflicting `EventId` is not None"); unconflicted_state.insert(key.clone(), id.clone()); } else { conflicted_state