Remove immediately-deref'ed double references

master
Jonas Platte 2020-07-11 21:20:02 +02:00
parent 85522ac35a
commit eea00301ff
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
3 changed files with 34 additions and 36 deletions

View File

@ -890,9 +890,9 @@ impl BaseClient {
/// ///
/// * `event` - The presence event for a specified room member. /// * `event` - The presence event for a specified room member.
pub async fn receive_account_data_event(&self, _: &RoomId, event: &AnyBasicEvent) -> bool { pub async fn receive_account_data_event(&self, _: &RoomId, event: &AnyBasicEvent) -> bool {
match &event { match event {
AnyBasicEvent::IgnoredUserList(event) => self.handle_ignored_users(&event).await, AnyBasicEvent::IgnoredUserList(event) => self.handle_ignored_users(event).await,
AnyBasicEvent::PushRules(event) => self.handle_push_rules(&event).await, AnyBasicEvent::PushRules(event) => self.handle_push_rules(event).await,
_ => false, _ => false,
} }
} }
@ -907,7 +907,7 @@ impl BaseClient {
/// ///
/// * `event` - The presence event for a specified room member. /// * `event` - The presence event for a specified room member.
pub async fn receive_ephemeral_event(&self, event: &AnyEphemeralRoomEventStub) -> bool { pub async fn receive_ephemeral_event(&self, event: &AnyEphemeralRoomEventStub) -> bool {
match &event { match event {
AnyEphemeralRoomEventStub::FullyRead(_) => {} AnyEphemeralRoomEventStub::FullyRead(_) => {}
AnyEphemeralRoomEventStub::Receipt(_) => {} AnyEphemeralRoomEventStub::Receipt(_) => {}
AnyEphemeralRoomEventStub::Typing(_) => {} AnyEphemeralRoomEventStub::Typing(_) => {}
@ -1471,44 +1471,42 @@ impl BaseClient {
} }
}; };
match &event { match event {
AnyRoomEventStub::State(event) => match &event { AnyRoomEventStub::State(event) => match event {
AnyStateEventStub::RoomMember(e) => event_emitter.on_room_member(room, &e).await, AnyStateEventStub::RoomMember(e) => event_emitter.on_room_member(room, e).await,
AnyStateEventStub::RoomName(e) => event_emitter.on_room_name(room, &e).await, AnyStateEventStub::RoomName(e) => event_emitter.on_room_name(room, e).await,
AnyStateEventStub::RoomCanonicalAlias(e) => { AnyStateEventStub::RoomCanonicalAlias(e) => {
event_emitter.on_room_canonical_alias(room, &e).await event_emitter.on_room_canonical_alias(room, e).await
} }
AnyStateEventStub::RoomAliases(e) => event_emitter.on_room_aliases(room, &e).await, AnyStateEventStub::RoomAliases(e) => event_emitter.on_room_aliases(room, e).await,
AnyStateEventStub::RoomAvatar(e) => event_emitter.on_room_avatar(room, &e).await, AnyStateEventStub::RoomAvatar(e) => event_emitter.on_room_avatar(room, e).await,
AnyStateEventStub::RoomPowerLevels(e) => { AnyStateEventStub::RoomPowerLevels(e) => {
event_emitter.on_room_power_levels(room, &e).await event_emitter.on_room_power_levels(room, e).await
} }
AnyStateEventStub::RoomTombstone(e) => { AnyStateEventStub::RoomTombstone(e) => {
event_emitter.on_room_tombstone(room, &e).await event_emitter.on_room_tombstone(room, e).await
} }
AnyStateEventStub::RoomJoinRules(e) => { AnyStateEventStub::RoomJoinRules(e) => {
event_emitter.on_room_join_rules(room, &e).await event_emitter.on_room_join_rules(room, e).await
} }
AnyStateEventStub::Custom(e) => { AnyStateEventStub::Custom(e) => {
event_emitter event_emitter
.on_unrecognized_event(room, &CustomOrRawEvent::State(&e)) .on_unrecognized_event(room, &CustomOrRawEvent::State(e))
.await .await
} }
_ => {} _ => {}
}, },
AnyRoomEventStub::Message(event) => match &event { AnyRoomEventStub::Message(event) => match event {
AnyMessageEventStub::RoomMessage(e) => { AnyMessageEventStub::RoomMessage(e) => event_emitter.on_room_message(room, e).await,
event_emitter.on_room_message(room, &e).await
}
AnyMessageEventStub::RoomMessageFeedback(e) => { AnyMessageEventStub::RoomMessageFeedback(e) => {
event_emitter.on_room_message_feedback(room, &e).await event_emitter.on_room_message_feedback(room, e).await
} }
AnyMessageEventStub::RoomRedaction(e) => { AnyMessageEventStub::RoomRedaction(e) => {
event_emitter.on_room_redaction(room, e).await event_emitter.on_room_redaction(room, e).await
} }
AnyMessageEventStub::Custom(e) => { AnyMessageEventStub::Custom(e) => {
event_emitter event_emitter
.on_unrecognized_event(room, &CustomOrRawEvent::Message(&e)) .on_unrecognized_event(room, &CustomOrRawEvent::Message(e))
.await .await
} }
_ => {} _ => {}

View File

@ -746,27 +746,27 @@ impl Room {
/// ///
/// * `event` - The event of the room. /// * `event` - The event of the room.
pub fn receive_timeline_event(&mut self, event: &AnyRoomEventStub) -> bool { pub fn receive_timeline_event(&mut self, event: &AnyRoomEventStub) -> bool {
match &event { match event {
AnyRoomEventStub::State(event) => match &event { AnyRoomEventStub::State(event) => match event {
// update to the current members of the room // update to the current members of the room
AnyStateEventStub::RoomMember(event) => self.handle_membership(&event), AnyStateEventStub::RoomMember(event) => self.handle_membership(event),
// finds all events related to the name of the room for later use // finds all events related to the name of the room for later use
AnyStateEventStub::RoomName(event) => self.handle_room_name(&event), AnyStateEventStub::RoomName(event) => self.handle_room_name(event),
AnyStateEventStub::RoomCanonicalAlias(event) => self.handle_canonical(&event), AnyStateEventStub::RoomCanonicalAlias(event) => self.handle_canonical(event),
AnyStateEventStub::RoomAliases(event) => self.handle_room_aliases(&event), AnyStateEventStub::RoomAliases(event) => self.handle_room_aliases(event),
// power levels of the room members // power levels of the room members
AnyStateEventStub::RoomPowerLevels(event) => self.handle_power_level(&event), AnyStateEventStub::RoomPowerLevels(event) => self.handle_power_level(event),
AnyStateEventStub::RoomTombstone(event) => self.handle_tombstone(&event), AnyStateEventStub::RoomTombstone(event) => self.handle_tombstone(event),
AnyStateEventStub::RoomEncryption(event) => self.handle_encryption_event(&event), AnyStateEventStub::RoomEncryption(event) => self.handle_encryption_event(event),
_ => false, _ => false,
}, },
AnyRoomEventStub::Message(event) => match &event { AnyRoomEventStub::Message(event) => match event {
#[cfg(feature = "messages")] #[cfg(feature = "messages")]
// We ignore this variants event because `handle_message` takes the enum // We ignore this variants event because `handle_message` takes the enum
// to store AnyMessageEventStub events in the `MessageQueue`. // to store AnyMessageEventStub events in the `MessageQueue`.
AnyMessageEventStub::RoomMessage(_) => self.handle_message(&event), AnyMessageEventStub::RoomMessage(_) => self.handle_message(event),
#[cfg(feature = "messages")] #[cfg(feature = "messages")]
AnyMessageEventStub::RoomRedaction(event) => self.handle_redaction(&event), AnyMessageEventStub::RoomRedaction(event) => self.handle_redaction(event),
_ => false, _ => false,
}, },
} }
@ -804,7 +804,7 @@ impl Room {
/// * `event` - The `AnyStrippedStateEvent` sent by the server for invited but not /// * `event` - The `AnyStrippedStateEvent` sent by the server for invited but not
/// joined rooms. /// joined rooms.
pub fn receive_stripped_state_event(&mut self, event: &AnyStrippedStateEventStub) -> bool { pub fn receive_stripped_state_event(&mut self, event: &AnyStrippedStateEventStub) -> bool {
match &event { match event {
AnyStrippedStateEventStub::RoomName(event) => self.handle_stripped_room_name(event), AnyStrippedStateEventStub::RoomName(event) => self.handle_stripped_room_name(event),
_ => false, _ => false,
} }

View File

@ -1333,7 +1333,7 @@ impl OlmMachine {
match &event { match &event {
AnyToDeviceEvent::RoomEncrypted(e) => { AnyToDeviceEvent::RoomEncrypted(e) => {
let decrypted_event = match self.decrypt_to_device_event(&e).await { let decrypted_event = match self.decrypt_to_device_event(e).await {
Ok(e) => e, Ok(e) => e,
Err(err) => { Err(err) => {
warn!( warn!(
@ -1350,7 +1350,7 @@ impl OlmMachine {
// before we replace the result. // before we replace the result.
*event_result = decrypted_event; *event_result = decrypted_event;
} }
AnyToDeviceEvent::RoomKeyRequest(e) => self.handle_room_key_request(&e), AnyToDeviceEvent::RoomKeyRequest(e) => self.handle_room_key_request(e),
AnyToDeviceEvent::KeyVerificationAccept(..) AnyToDeviceEvent::KeyVerificationAccept(..)
| AnyToDeviceEvent::KeyVerificationCancel(..) | AnyToDeviceEvent::KeyVerificationCancel(..)
| AnyToDeviceEvent::KeyVerificationKey(..) | AnyToDeviceEvent::KeyVerificationKey(..)