From c29e05bc2583d5126f3100d3d7908f742143155f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 4 Feb 2019 00:24:39 +0100 Subject: [PATCH] Simplify implementation of ContactStore::all_contacts() This way we alter the underlying iterator for all contacts to only iterate in the "contact" collection of the store, which results in fewer disk access because the internal iterator does not yield all pathes from the store before filtering them. Signed-off-by: Matthias Beyer --- lib/domain/libimagcontact/src/store.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/domain/libimagcontact/src/store.rs b/lib/domain/libimagcontact/src/store.rs index dc2fa5a5..b39d4e04 100644 --- a/lib/domain/libimagcontact/src/store.rs +++ b/lib/domain/libimagcontact/src/store.rs @@ -77,15 +77,7 @@ impl<'a> ContactStore<'a> for Store { } fn all_contacts(&'a self) -> Result { - let iter = self - .entries()? - .without_store() - .filter(|id| match *id { - Ok(ref id) => id.is_in_collection(&["contact"]), - Err(_) => true, - }); - - Ok(StoreIdIterator::new(Box::new(iter))) + self.entries().map(|iter| iter.in_collection("contact").without_store()) } }