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 <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-02-04 00:24:39 +01:00
parent eed577db15
commit c29e05bc25

View file

@ -77,15 +77,7 @@ impl<'a> ContactStore<'a> for Store {
} }
fn all_contacts(&'a self) -> Result<StoreIdIterator> { fn all_contacts(&'a self) -> Result<StoreIdIterator> {
let iter = self self.entries().map(|iter| iter.in_collection("contact").without_store())
.entries()?
.without_store()
.filter(|id| match *id {
Ok(ref id) => id.is_in_collection(&["contact"]),
Err(_) => true,
});
Ok(StoreIdIterator::new(Box::new(iter)))
} }
} }