Skip to content

Commit

Permalink
Merge pull request #318 from cuviper/cautious_capacity
Browse files Browse the repository at this point in the history
Simplify `cautious_capacity` since `Bucket` is never a ZST
  • Loading branch information
cuviper committed Feb 29, 2024
2 parents 43b322e + 7e64de1 commit cdebfe8
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 cdebfe8

Please sign in to comment.