From 134d82a08b36a09bf1dd887f562e036858f39574 Mon Sep 17 00:00:00 2001 From: mehbark Date: Thu, 28 Nov 2024 17:01:18 -0500 Subject: [PATCH] preallocate --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 6208702..bf9e3de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,9 @@ fn main() { args.next().unwrap(); let min_syllables: usize = args.next().expect("one arg").parse().expect("a number"); - let mut message = String::with_capacity(128); + // the vast, vast majority of discord messages are under 2000 chars, so this avoids + // reallocating + let mut message = String::with_capacity(2048); io::stdin() .read_to_string(&mut message) .expect("i want a message");