Improve count_credentials by not deserializing them

This commit is contained in:
Julien Cretin
2021-01-25 17:04:01 +01:00
parent 846ff279bb
commit 0e537733f1

View File

@@ -268,11 +268,11 @@ impl PersistentStore {
/// Returns the number of credentials. /// Returns the number of credentials.
pub fn count_credentials(&self) -> Result<usize, Ctap2StatusCode> { pub fn count_credentials(&self) -> Result<usize, Ctap2StatusCode> {
let mut iter_result = Ok(()); let mut count = 0;
let iter = self.iter_credentials(&mut iter_result)?; for handle in self.store.iter()? {
let result = iter.count(); count += key::CREDENTIALS.contains(&handle?.get_key()) as usize;
iter_result?; }
Ok(result) Ok(count)
} }
/// Returns the estimated number of credentials that can still be stored. /// Returns the estimated number of credentials that can still be stored.