reduce unnecessary clone in pdu handler

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-10-22 07:07:42 +00:00 committed by strawberry
parent b8260e0104
commit dd6621a720

View file

@ -118,15 +118,12 @@ async fn handle_pdus(
.lock(&room_id) .lock(&room_id)
.await; .await;
resolved_map.insert( let result = services
event_id.clone(),
services
.rooms .rooms
.event_handler .event_handler
.handle_incoming_pdu(origin, &room_id, &event_id, value, true) .handle_incoming_pdu(origin, &room_id, &event_id, value, true)
.await .await
.map(|_| ()), .map(|_| ());
);
drop(mutex_lock); drop(mutex_lock);
debug!( debug!(
@ -134,12 +131,14 @@ async fn handle_pdus(
txn_elapsed = ?txn_start_time.elapsed(), txn_elapsed = ?txn_start_time.elapsed(),
"Finished PDU {event_id}", "Finished PDU {event_id}",
); );
resolved_map.insert(event_id, result);
} }
for pdu in &resolved_map { for (id, result) in &resolved_map {
if let Err(e) = pdu.1 { if let Err(e) = result {
if matches!(e, Error::BadRequest(ErrorKind::NotFound, _)) { if matches!(e, Error::BadRequest(ErrorKind::NotFound, _)) {
warn!("Incoming PDU failed {pdu:?}"); warn!("Incoming PDU failed {id}: {e:?}");
} }
} }
} }