From a6eecdbf54f007e7fe4b57b3375c9315af03de18 Mon Sep 17 00:00:00 2001 From: monosans Date: Thu, 24 Apr 2025 13:54:32 +0300 Subject: [PATCH] perf: reduce hashset allocations when scraping --- src/scraper.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scraper.rs b/src/scraper.rs index f7b5333..d759eaf 100644 --- a/src/scraper.rs +++ b/src/scraper.rs @@ -55,7 +55,6 @@ async fn scrape_one( tx.send(Event::App(AppEvent::SourceScraped(proto.clone())))?; - let mut proxies = HashSet::new(); let text = match text_result { Ok(text) => text, Err(e) => { @@ -67,7 +66,7 @@ async fn scrape_one( .collect::>() .join(" \u{2192} "), ); - return Ok(proxies); + return Ok(HashSet::new()); } }; @@ -75,7 +74,7 @@ async fn scrape_one( if matches.is_empty() { log::warn!("{source} | No proxies found"); - return Ok(proxies); + return Ok(HashSet::new()); } if config.proxies_per_source_limit != 0 @@ -86,9 +85,10 @@ async fn scrape_one( source, matches.len(), ); - return Ok(proxies); + return Ok(HashSet::new()); } + let mut proxies = HashSet::with_capacity(matches.len()); for capture in matches { let capture = capture.unwrap(); let proxy = Proxy {