diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-07-26 22:46:48 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-07-26 22:46:48 +0200 |
| commit | 8dbfc9613673be00304d5efc08815a64f7b1ccca (patch) | |
| tree | 6ffdeba30a738ecaf417bde49e4b2d472296d552 /src/index.rs | |
| parent | b1645aa2047cbfed040a40e8f4ed2a92765dc287 (diff) | |
use binary search for vector matching instead of hashmaps
Diffstat (limited to 'src/index.rs')
| -rw-r--r-- | src/index.rs | 3 |
1 files changed, 2 insertions, 1 deletions
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<SearchResult> = 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; |