From 8dbfc9613673be00304d5efc08815a64f7b1ccca Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 26 Jul 2023 22:46:48 +0200 Subject: use binary search for vector matching instead of hashmaps --- src/index.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/index.rs') diff --git a/src/index.rs b/src/index.rs index 5d2abb6..d3aab9e 100644 --- a/src/index.rs +++ b/src/index.rs @@ -149,6 +149,7 @@ impl Index { let opt = FileVector::from_hashmap(opt); let mut results : Vec = Vec::new(); + let max = self.filecache.len(); let mut last_p = 0; for (i, filecache) in self.filecache.iter().enumerate() { @@ -159,7 +160,7 @@ impl Index { results.push(r); } - let p = i * 100 / self.filecache.len(); + let p = i * 100 / max; if last_p < p { callback(p as u8); last_p = p; -- cgit v1.2.3-70-g09d2