From 4e8abeceaa976b9eaf8b0e4ec58a79ba7b0eebfc Mon Sep 17 00:00:00 2001 From: Liam Gray Date: Thu, 5 Dec 2024 00:35:17 +0000 Subject: [PATCH] perf: reduce to_vec default buffer capacities Signed-off-by: Liam Gray --- ciborium/src/ser/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ciborium/src/ser/mod.rs b/ciborium/src/ser/mod.rs index 4bf393b..1699fa9 100644 --- a/ciborium/src/ser/mod.rs +++ b/ciborium/src/ser/mod.rs @@ -738,7 +738,7 @@ where fn to_vec_small( value: &T, ) -> Result, Error> { - let mut buffer = Vec::with_capacity(256); + let mut buffer = Vec::with_capacity(32); let mut serializer: Serializer<_, C> = Serializer::new(&mut buffer); value.serialize(&mut serializer)?; Ok(buffer) @@ -765,7 +765,7 @@ fn to_vec_small( #[cfg(feature = "std")] #[inline] pub fn to_vec(value: &T) -> Result, Error> { - let mut buffer = Vec::with_capacity(1024); + let mut buffer = Vec::with_capacity(128); let mut serializer: Serializer<_, NoCanonicalization> = Serializer::new(&mut buffer); value.serialize(&mut serializer)?; Ok(buffer) @@ -795,7 +795,7 @@ pub fn to_vec(value: &T) -> Result, Error( value: &T, ) -> Result, Error> { - let mut buffer = Vec::with_capacity(1024); + let mut buffer = Vec::with_capacity(128); let mut serializer: Serializer<_, C> = Serializer::new(&mut buffer); value.serialize(&mut serializer)?; Ok(buffer)