mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-02 15:25:38 +00:00
Call reserve()
in DeserializeSeed
example
This suggests calling `reserve()` in example code so that people who ~blindly copy it get faster code.
This commit is contained in:
parent
845b900fd5
commit
41ffa6df7e
@ -708,6 +708,11 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
|
|||||||
/// where
|
/// where
|
||||||
/// A: SeqAccess<'de>,
|
/// A: SeqAccess<'de>,
|
||||||
/// {
|
/// {
|
||||||
|
/// // Decrease the number of reallocations if there are many elements
|
||||||
|
/// if let Some(size_hint) = seq.size_hint() {
|
||||||
|
/// self.0.reserve(size_hint);
|
||||||
|
/// }
|
||||||
|
///
|
||||||
/// // Visit each element in the inner array and push it onto
|
/// // Visit each element in the inner array and push it onto
|
||||||
/// // the existing vector.
|
/// // the existing vector.
|
||||||
/// while let Some(elem) = seq.next_element()? {
|
/// while let Some(elem) = seq.next_element()? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user