Skip to content

Commit

Permalink
review(sami): let event getter return a reference to avoid copying
Browse files Browse the repository at this point in the history
  • Loading branch information
mariocynicys committed Nov 18, 2024
1 parent 5f775d6 commit f5dbfdd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions mm2src/mm2_event_stream/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ impl Event {
pub fn origin(&self) -> &str { &self.event_type }

/// Returns the event type and message as a pair.
pub fn get(&self) -> (String, Json) {
pub fn get(&self) -> (String, &Json) {
let prefix = if self.error { "ERROR:" } else { "" };
(format!("{prefix}{}", self.event_type), self.message.clone())
(format!("{prefix}{}", self.event_type), &self.message)
}
}
2 changes: 1 addition & 1 deletion mm2src/mm2_event_stream/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ mod tests {
let event = client1.try_recv().unwrap();
assert_eq!(event.origin(), streamer_id);
// It's an echo streamer, so the message should be the same.
assert_eq!(event.get().1, json!(msg));
assert_eq!(event.get().1, &json!(msg));
}

// If we send the wrong datatype (void here instead of String), the streamer should ignore it.
Expand Down

0 comments on commit f5dbfdd

Please sign in to comment.