...@@ -37,6 +37,17 @@ dependencies = [ ...@@ -37,6 +37,17 @@ dependencies = [
"version_check", "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]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.7.20" version = "0.7.20"
...@@ -603,7 +614,7 @@ version = "0.11.2" ...@@ -603,7 +614,7 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [ dependencies = [
"ahash", "ahash 0.7.6",
] ]
[[package]] [[package]]
...@@ -612,6 +623,15 @@ version = "0.12.3" ...@@ -612,6 +623,15 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 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]] [[package]]
name = "hashlink" name = "hashlink"
version = "0.7.0" version = "0.7.0"
...@@ -807,11 +827,11 @@ dependencies = [ ...@@ -807,11 +827,11 @@ dependencies = [
[[package]] [[package]]
name = "lru" name = "lru"
version = "0.6.6" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ea2d928b485416e8908cff2d97d621db22b27f7b3b6729e438bcf42c671ba91" checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e"
dependencies = [ dependencies = [
"hashbrown 0.11.2", "hashbrown 0.13.2",
] ]
[[package]] [[package]]
......
...@@ -22,7 +22,7 @@ chrono = "0.4.23" ...@@ -22,7 +22,7 @@ chrono = "0.4.23"
enumber = "0.3" enumber = "0.3"
lazy_static = "1" lazy_static = "1"
libc = "0.2" libc = "0.2"
lru = "0.6.6" lru = "0.10.0"
memmem = "0.1" memmem = "0.1"
memoffset = "0.6" memoffset = "0.6"
# When bumping the version of Sequoia search the code for XXX to find # When bumping the version of Sequoia search the code for XXX to find
......
...@@ -46,7 +46,8 @@ const CACHE_HASH: HashAlgorithm = HashAlgorithm::SHA256; ...@@ -46,7 +46,8 @@ const CACHE_HASH: HashAlgorithm = HashAlgorithm::SHA256;
// The number of entries in the cache. Do not make this too big since // The number of entries in the cache. Do not make this too big since
// we iterate over the cache to purge stale entries. // 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<Vec<u8>, Cert>; type CertCache = LruCache<Vec<u8>, Cert>;
...@@ -359,13 +360,14 @@ impl Keystore { ...@@ -359,13 +360,14 @@ impl Keystore {
.map(|(digest, cert)| (digest, cert.fingerprint())) .map(|(digest, cert)| (digest, cert.fingerprint()))
.filter(|(_digest, other)| &fpr == other) .filter(|(_digest, other)| &fpr == other)
.map(|(digest, _)| digest) .map(|(digest, _)| digest)
.collect::<Vec<_>>(); .cloned()
.collect::<Vec<Vec<u8>>>();
if purge.len() > 0 { if purge.len() > 0 {
t!("Purging {} stale entries that also map to {}", t!("Purging {} stale entries that also map to {}",
purge.len(), fpr); purge.len(), fpr);
} }
for stale_digest in purge { for stale_digest in purge {
cache.pop(stale_digest); cache.pop(&stale_digest);
} }
// Add the new entry to the cache. // Add the new entry to the cache.
......