From dc031fff95594fbf572a8a7564f761518e9889d2 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 5 Apr 2021 21:46:10 +0200 Subject: [PATCH] Remove redundant calls to .iter() and .into_iter() --- src/database/rooms.rs | 2 +- src/server_server.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/database/rooms.rs b/src/database/rooms.rs index ef1e558..b2043d1 100644 --- a/src/database/rooms.rs +++ b/src/database/rooms.rs @@ -531,7 +531,7 @@ impl Rooms { self.roomid_pduleaves.remove(key?)?; } - for event_id in event_ids.iter() { + for event_id in event_ids { let mut key = prefix.to_owned(); key.extend_from_slice(event_id.as_bytes()); self.roomid_pduleaves.insert(&key, event_id.as_bytes())?; diff --git a/src/server_server.rs b/src/server_server.rs index bb0b9af..421b4f8 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -552,7 +552,7 @@ pub async fn send_transaction_message_route<'a>( // events that it references. let mut auth_cache = EventMap::new(); - for pdu in body.pdus.iter() { + for pdu in &body.pdus { // We do not add the event_id field to the pdu here because of signature and hashes checks let (event_id, value) = match crate::pdu::gen_event_id_canonical_json(pdu) { Ok(t) => t, @@ -757,7 +757,7 @@ fn handle_incoming_pdu<'a>( // Build map of auth events let mut auth_events = BTreeMap::new(); - for id in incoming_pdu.auth_events.iter() { + for id in &incoming_pdu.auth_events { let auth_event = auth_cache.get(id).ok_or_else(|| { "Auth event not found, event failed recursive auth checks.".to_string() })?; @@ -869,7 +869,7 @@ fn handle_incoming_pdu<'a>( }; let mut state = BTreeMap::new(); - for pdu in state_vec.into_iter() { + for pdu in state_vec { match state.entry((pdu.kind.clone(), pdu.state_key.clone().ok_or_else(|| "Found non-state pdu in state events.".to_owned())?)) { Entry::Vacant(v) => { v.insert(pdu); @@ -1268,7 +1268,7 @@ pub(crate) async fn fetch_signing_keys( .await { debug!("Got signing keys: {:?}", keys); - for k in keys.server_keys.into_iter() { + for k in keys.server_keys { db.globals.add_signing_key(origin, &k)?; result.extend( k.verify_keys