From 778c5a053bc4fffd53a25a450f7e6fdfbf93d41a Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 18 Nov 2024 10:57:28 -0800 Subject: [PATCH] ratelimit: reduce the number of string allocations not a huge deal, but this is technically a bit nicer --- src/filters/ratelimit.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/filters/ratelimit.rs b/src/filters/ratelimit.rs index 44cb514..c4281b9 100644 --- a/src/filters/ratelimit.rs +++ b/src/filters/ratelimit.rs @@ -63,14 +63,15 @@ impl NoteFilter for RateLimit { } if entry.tokens == 0 { + let message = self + .message + .as_deref() + .unwrap_or("rate-limited: you are noting too much"); + return OutputMessage::new( msg.event.id.clone(), Action::Reject, - Some( - self.message - .clone() - .unwrap_or("rate-limited: you are noting too much".to_string()), - ), + Some(message.to_owned()), ); }