summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/mod.rs
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-11-07 11:48:23 +0100
committerNeal H. Walfield <neal@pep.foundation>2019-11-07 12:04:51 +0100
commit5bbd9b88f6c49f7e22a6bc817b8bdf251565f460 (patch)
tree60f994707b87fc919c85040ef6fce5ddf3e6b4c3 /openpgp/src/crypto/mod.rs
parentec1063a3c684b5c44886907b2a9817ff2e557be7 (diff)
openpgp: Use a Vec instead of a HashMap.
- A SignatureGroup currently contains a hash mapping hash algorithms to hash contexts. Typically this will only contain one or two mappings. At most it will contain one mapping for each algorithm that we support (currently, we support 7 hash algorithms). - Given the small expected and small maximum size, a vector is the better data structure: - The small number of elements means that look up time will be comparable whether we do a linear scan or look in a hash (in fact, the linear scan is probably cache friendlier). - Iterating over a vector is faster than iterating over a hash map. The is the fast path. - A vector takes up less space. - Change SignatureGroup::hashes to use a Vec instead of a HashMap.
Diffstat (limited to 'openpgp/src/crypto/mod.rs')
-rw-r--r--openpgp/src/crypto/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs
index 77895837..150014cc 100644
--- a/openpgp/src/crypto/mod.rs
+++ b/openpgp/src/crypto/mod.rs
@@ -193,7 +193,7 @@ pub fn hash_file<R: Read>(reader: R, algos: &[HashAlgorithm])
let mut hashes =
mem::replace(&mut reader.cookie_mut().sig_group_mut().hashes,
Default::default());
- let hashes = hashes.drain().collect();
+ let hashes = hashes.drain(..).collect();
Ok(hashes)
}