diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-07-14 00:22:39 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-07-14 00:22:39 +0200 |
| commit | 149e0b6ae9871515be21f23b492f5ef7355e2ca4 (patch) | |
| tree | d5b1bf8281a3a1cf181d5c921a53dfd99fd8b7a9 /src/filecache.rs | |
| parent | 0723ea6b6bb6832b11582eeb8a330d2bdb6077b5 (diff) | |
make fast using hash instead of dictionary
Diffstat (limited to 'src/filecache.rs')
| -rw-r--r-- | src/filecache.rs | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/filecache.rs b/src/filecache.rs index af97c20..721d7a4 100644 --- a/src/filecache.rs +++ b/src/filecache.rs @@ -1,9 +1,9 @@ use std::hash::{Hasher, Hash}; - +use serde::{Deserialize, Serialize}; use crate::vector::FileVector; /// Represents one file which was indexed. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct FileCache { pub path : String, pub vector : FileVector, @@ -22,15 +22,3 @@ impl Hash for FileCache { self.path.hash(state); } } - -impl FileCache { - pub fn from_line(line : String) -> Self { - let ls : Vec<String> = line.split(',').map(|s| s.to_string()).collect(); - let v = FileVector::from_string(&ls[1]); - let p = ls[0].clone().replace('\0', ","); - Self { - vector : v, - path : p - } - } -} |