mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 09:01:01 +00:00
Also clamp the collection impls
This commit is contained in:
@@ -30,6 +30,8 @@ use std::collections::{
|
|||||||
#[cfg(feature = "collections")]
|
#[cfg(feature = "collections")]
|
||||||
use collections::borrow::ToOwned;
|
use collections::borrow::ToOwned;
|
||||||
|
|
||||||
|
#[cfg(any(feature = "std", feature = "collections"))]
|
||||||
|
use core::cmp;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use core::hash::{Hash, BuildHasher};
|
use core::hash::{Hash, BuildHasher};
|
||||||
@@ -467,7 +469,7 @@ seq_impl!(
|
|||||||
BinaryHeapVisitor<T: Deserialize + Ord>,
|
BinaryHeapVisitor<T: Deserialize + Ord>,
|
||||||
visitor,
|
visitor,
|
||||||
BinaryHeap::new(),
|
BinaryHeap::new(),
|
||||||
BinaryHeap::with_capacity(visitor.size_hint().0),
|
BinaryHeap::with_capacity(cmp::min(visitor.size_hint().0, 4096)),
|
||||||
BinaryHeap::push);
|
BinaryHeap::push);
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "collections"))]
|
#[cfg(any(feature = "std", feature = "collections"))]
|
||||||
@@ -495,7 +497,7 @@ seq_impl!(
|
|||||||
S: BuildHasher + Default>,
|
S: BuildHasher + Default>,
|
||||||
visitor,
|
visitor,
|
||||||
HashSet::with_hasher(S::default()),
|
HashSet::with_hasher(S::default()),
|
||||||
HashSet::with_capacity_and_hasher(visitor.size_hint().0, S::default()),
|
HashSet::with_capacity_and_hasher(cmp::min(visitor.size_hint().0, 4096), S::default()),
|
||||||
HashSet::insert);
|
HashSet::insert);
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "collections"))]
|
#[cfg(any(feature = "std", feature = "collections"))]
|
||||||
@@ -504,7 +506,7 @@ seq_impl!(
|
|||||||
VecVisitor<T: Deserialize>,
|
VecVisitor<T: Deserialize>,
|
||||||
visitor,
|
visitor,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
Vec::with_capacity(visitor.size_hint().0),
|
Vec::with_capacity(cmp::min(visitor.size_hint().0, 4096)),
|
||||||
Vec::push);
|
Vec::push);
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "collections"))]
|
#[cfg(any(feature = "std", feature = "collections"))]
|
||||||
@@ -513,7 +515,7 @@ seq_impl!(
|
|||||||
VecDequeVisitor<T: Deserialize>,
|
VecDequeVisitor<T: Deserialize>,
|
||||||
visitor,
|
visitor,
|
||||||
VecDeque::new(),
|
VecDeque::new(),
|
||||||
VecDeque::with_capacity(visitor.size_hint().0),
|
VecDeque::with_capacity(cmp::min(visitor.size_hint().0, 4096)),
|
||||||
VecDeque::push_back);
|
VecDeque::push_back);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -791,7 +793,7 @@ map_impl!(
|
|||||||
S: BuildHasher + Default>,
|
S: BuildHasher + Default>,
|
||||||
visitor,
|
visitor,
|
||||||
HashMap::with_hasher(S::default()),
|
HashMap::with_hasher(S::default()),
|
||||||
HashMap::with_capacity_and_hasher(visitor.size_hint().0, S::default()));
|
HashMap::with_capacity_and_hasher(cmp::min(visitor.size_hint().0, 4096), S::default()));
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user