Rewrite Store::load_in_cache() to check cache before loading

This commit is contained in:
Matthias Beyer 2016-01-01 23:26:04 +01:00
parent 6c92b2300c
commit f802b00974

View file

@ -60,6 +60,7 @@ impl Store {
-> Option<Rc<RefCell<File>>> -> Option<Rc<RefCell<File>>>
where HP: FileHeaderParser where HP: FileHeaderParser
{ {
self.load(&id).or({
let idstr : String = id.clone().into(); let idstr : String = id.clone().into();
let path = format!("{}/{}-{}.imag", self.storepath, m.name(), idstr); let path = format!("{}/{}-{}.imag", self.storepath, m.name(), idstr);
debug!("Loading path = '{}'", path); debug!("Loading path = '{}'", path);
@ -72,9 +73,9 @@ impl Store {
parser.read(string).map(|(header, data)| { parser.read(string).map(|(header, data)| {
self.new_file_from_parser_result(m, id.clone(), header, data); self.new_file_from_parser_result(m, id.clone(), header, data);
});
self.load(&id) self.load(&id)
}).unwrap_or(None)
})
} }
/** /**