From e5e4dd0ae62d231ae7bca6b2af36719ae1422d56 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 7 Jul 2025 02:42:05 +0300 Subject: [PATCH] store index values in memory only in use by the argument options --- src/index.rs | 8 ++++++-- src/main.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/index.rs b/src/index.rs index b78c601..c87df24 100644 --- a/src/index.rs +++ b/src/index.rs @@ -14,13 +14,17 @@ pub struct Index { /// Track index changes to prevent extra disk write operations (safe SSD life) /// * useful in the static RSS feed generation case, if enabled. is_changed: bool, + /// Store index value in memory only on it is in use + /// by the externally defined argument options. + has_name: bool, } impl Index { - pub fn init(capacity: usize) -> Self { + pub fn init(capacity: usize, has_name: bool) -> Self { Self { index: HashMap::with_capacity(capacity), is_changed: false, + has_name, } } @@ -52,7 +56,7 @@ impl Index { Value { time: Utc::now(), node, - name, + name: if self.has_name { name } else { None }, }, ) .is_none() diff --git a/src/main.rs b/src/main.rs index aa8b5dd..49202b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,7 +64,7 @@ async fn main() -> Result<()> { // begin debug.info("Crawler started"); - let mut index = Index::init(config.index_capacity); + let mut index = Index::init(config.index_capacity, config.export_rss.is_some()); loop { debug.info("Index queue begin..."); index.refresh();