From 513e5b2f74eb4697e5b0ed3952b1e3cf60ac6f0b Mon Sep 17 00:00:00 2001 From: Geoffry Song Date: Sat, 18 Jan 2025 15:38:08 -0800 Subject: [PATCH] Use Map::with_capacity in value::Serializer::serialize_map --- src/value/ser.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/value/ser.rs b/src/value/ser.rs index a68193437..1ffe7b7f1 100644 --- a/src/value/ser.rs +++ b/src/value/ser.rs @@ -261,9 +261,9 @@ impl serde::Serializer for Serializer { }) } - fn serialize_map(self, _len: Option) -> Result { + fn serialize_map(self, len: Option) -> Result { Ok(SerializeMap::Map { - map: Map::new(), + map: Map::with_capacity(len.unwrap_or(0)), next_key: None, }) }