Skip to content

Commit

Permalink
Simplify cautious_capacity since Bucket is never a ZST
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Feb 29, 2024
1 parent 43b322e commit 7e64de1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ use crate::{Bucket, IndexMap, IndexSet};
pub(crate) fn cautious_capacity<K, V>(hint: Option<usize>) -> usize {
const MAX_PREALLOC_BYTES: usize = 1024 * 1024;

if mem::size_of::<Bucket<K, V>>() == 0 {
0
} else {
cmp::min(
hint.unwrap_or(0),
MAX_PREALLOC_BYTES / mem::size_of::<Bucket<K, V>>(),
)
}
cmp::min(
hint.unwrap_or(0),
MAX_PREALLOC_BYTES / mem::size_of::<Bucket<K, V>>(),
)
}

impl<K, V, S> Serialize for IndexMap<K, V, S>
Expand Down

0 comments on commit 7e64de1

Please sign in to comment.