From 789783cfe472525c5f1bee3a5cd224638bc0f4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Wed, 8 Apr 2020 20:23:31 +0200 Subject: [PATCH] aquatic scrape handler: preallocate stats vec better --- aquatic/src/lib/handlers.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aquatic/src/lib/handlers.rs b/aquatic/src/lib/handlers.rs index 26f2b6b..8d32a34 100644 --- a/aquatic/src/lib/handlers.rs +++ b/aquatic/src/lib/handlers.rs @@ -141,7 +141,10 @@ pub fn handle_scrape_requests( if !state.connections.contains_key(&connection_key){ return None; } - let mut stats: Vec = Vec::with_capacity(256); + + let mut stats: Vec = Vec::with_capacity( + request.info_hashes.len() + ); for info_hash in request.info_hashes.iter() { if let Some(torrent_data) = state.torrents.get(info_hash){