diff --git a/Cargo.lock b/Cargo.lock index cf619001163de2641a82bee6d0dc5f4ff19d2e50..97800ad7f95f1855a1f83cbdfd05a60897a4db0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,6 +37,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.20" @@ -603,7 +614,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash", + "ahash 0.7.6", ] [[package]] @@ -612,6 +623,15 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", +] + [[package]] name = "hashlink" version = "0.7.0" @@ -807,11 +827,11 @@ dependencies = [ [[package]] name = "lru" -version = "0.6.6" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea2d928b485416e8908cff2d97d621db22b27f7b3b6729e438bcf42c671ba91" +checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" dependencies = [ - "hashbrown 0.11.2", + "hashbrown 0.13.2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5569dcf5426bb5ae83a5dd05cd0307f0b2af0a14..ee3f6dca0d4f004e9232830ba16b822ffdbb8771 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ chrono = "0.4.23" enumber = "0.3" lazy_static = "1" libc = "0.2" -lru = "0.6.6" +lru = "0.10.0" memmem = "0.1" memoffset = "0.6" # When bumping the version of Sequoia search the code for XXX to find diff --git a/src/keystore.rs b/src/keystore.rs index 0d2babc4bdfea807e37ad01783a7b4c62ee5214d..d6b096e143333dbf514cc9b51feedc421085e8e3 100644 --- a/src/keystore.rs +++ b/src/keystore.rs @@ -46,7 +46,8 @@ const CACHE_HASH: HashAlgorithm = HashAlgorithm::SHA256; // The number of entries in the cache. Do not make this too big since // we iterate over the cache to purge stale entries. -const CERT_CACHE_ENTRIES: usize = 32; +const CERT_CACHE_ENTRIES: std::num::NonZeroUsize + = unsafe { std::num::NonZeroUsize::new_unchecked(32) }; type CertCache = LruCache, Cert>; @@ -359,13 +360,14 @@ impl Keystore { .map(|(digest, cert)| (digest, cert.fingerprint())) .filter(|(_digest, other)| &fpr == other) .map(|(digest, _)| digest) - .collect::>(); + .cloned() + .collect::>>(); if purge.len() > 0 { t!("Purging {} stale entries that also map to {}", purge.len(), fpr); } for stale_digest in purge { - cache.pop(stale_digest); + cache.pop(&stale_digest); } // Add the new entry to the cache.