Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/mft.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmer Ben-Amram <omerbenamram@gmail.com>2019-05-31 15:50:32 +0300
committerOmer Ben-Amram <omerbenamram@gmail.com>2019-05-31 15:50:32 +0300
commit7892866d4a7428e13bd2a5bfc75ec859f76f847e (patch)
tree70f19f47445a18afe8f1a205ce429f6c5274d96d
parenta41cc02014c9c931de36bfbf00810be82eaa2b6a (diff)
faster LRU
-rw-r--r--Cargo.toml4
-rw-r--r--src/benches/benchmark.rs4
-rw-r--r--src/entry.rs1
-rw-r--r--src/mft.rs13
4 files changed, 9 insertions, 13 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 30ff0f9..460c4cc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,8 +23,8 @@ env_logger = "0.6.1"
snafu = {version="0.4.1", features = ["backtraces", "rust_1_30"]}
num-traits = "0.2"
num-derive = "0.2"
-winstructs = "0.1.1"
-cached = "0.8.0"
+winstructs = "0.2.0"
+lru = "0.1.15"
itertools = "0.8.0"
[dependencies.chrono]
diff --git a/src/benches/benchmark.rs b/src/benches/benchmark.rs
index 79695f0..b410096 100644
--- a/src/benches/benchmark.rs
+++ b/src/benches/benchmark.rs
@@ -17,10 +17,8 @@ fn process_1000_mft_records(sample: &[u8]) {
}
fn get_full_path(parser: &mut MftParser<impl ReadSeek>, entries: &[MftEntry]) {
- let mut paths = Vec::with_capacity(10000);
-
for entry in entries {
- paths.push(parser.get_full_path_for_entry(&entry));
+ parser.get_full_path_for_entry(&entry).unwrap();
}
}
diff --git a/src/entry.rs b/src/entry.rs
index 296ec2f..4ee46fc 100644
--- a/src/entry.rs
+++ b/src/entry.rs
@@ -19,7 +19,6 @@ use crate::attribute::{MftAttribute, MftAttributeContent, MftAttributeType};
use std::io::Read;
use std::io::SeekFrom;
use std::io::{Cursor, Seek};
-use std::path::PathBuf;
const SEQUENCE_NUMBER_STRIDE: usize = 512;
diff --git a/src/mft.rs b/src/mft.rs
index 94b0e62..5e6736a 100644
--- a/src/mft.rs
+++ b/src/mft.rs
@@ -8,8 +8,7 @@ use snafu::ResultExt;
use crate::attribute::MftAttributeContent::AttrX30;
use crate::attribute::x30::FileNamespace;
-use cached::stores::SizedCache;
-use cached::Cached;
+use lru::LruCache;
use std::fs::{self, File};
use std::io::{BufReader, Cursor, SeekFrom};
use std::path::{Path, PathBuf};
@@ -20,7 +19,7 @@ pub struct MftParser<T: ReadSeek> {
/// Instead this will be guessed by the entry size of the first entry.
entry_size: u32,
size: u64,
- entries_cache: SizedCache<u64, PathBuf>,
+ entries_cache: LruCache<u64, PathBuf>,
}
impl MftParser<BufReader<File>> {
@@ -63,7 +62,7 @@ impl<T: ReadSeek> MftParser<T> {
data,
entry_size: first_entry.total_entry_size,
size,
- entries_cache: SizedCache::with_size(1000),
+ entries_cache: LruCache::new(1000),
})
}
@@ -92,7 +91,7 @@ impl<T: ReadSeek> MftParser<T> {
}
fn inner_get_entry(&mut self, parent_entry_id: u64, entry_name: Option<&str>) -> PathBuf {
- let cached_entry = self.entries_cache.cache_get(&parent_entry_id);
+ let cached_entry = self.entries_cache.get(&parent_entry_id);
// If my parent path is known, then my path is parent's full path + my name.
// Else, retrieve and cache my parent's path.
@@ -113,7 +112,7 @@ impl<T: ReadSeek> MftParser<T> {
None => PathBuf::from("[Unknown]"),
};
- self.entries_cache.cache_set(parent_entry_id, path.clone());
+ self.entries_cache.put(parent_entry_id, path.clone());
match entry_name {
Some(name) => path.join(name),
None => path,
@@ -153,7 +152,7 @@ impl<T: ReadSeek> MftParser<T> {
let orphan = PathBuf::from("[Orphaned]").join(filename_header.name);
self.entries_cache
- .cache_set(entry.header.record_number, orphan.clone());
+ .put(entry.header.record_number, orphan.clone());
Ok(Some(orphan))
}