From 5e957355361ba2df209b2517faeed80b702d6973 Mon Sep 17 00:00:00 2001 From: Christopher Sardegna Date: Fri, 29 Aug 2025 11:29:31 -0700 Subject: [PATCH 1/2] Polishing --- src/deserializer/iter.rs | 11 ++++++----- src/deserializer/typedstream.rs | 5 ++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/deserializer/iter.rs b/src/deserializer/iter.rs index 61d8aa7..cf57d11 100644 --- a/src/deserializer/iter.rs +++ b/src/deserializer/iter.rs @@ -65,9 +65,10 @@ impl<'a, 'b> PropertyIterator<'a, 'b> { ) -> Option { let root_object = object_table.get(root_object_index)?; - let properties = if let Archived::Object { data, .. } = root_object { - data - } else { + let Archived::Object { + data: properties, .. + } = root_object + else { return None; }; @@ -105,7 +106,7 @@ impl<'a, 'b: 'a> PropertyIterator<'a, 'b> { /// ``` #[must_use] pub fn primitives(self) -> Vec<&'b OutputData<'a>> { - self.primitives_with_limits(100, 1000000) + self.primitives_with_limits(100, 1_000_000) } /// Collects primitive data values with safety limits to prevent infinite loops. @@ -254,7 +255,7 @@ impl<'a, 'b: 'a> Iterator for PropertyIterator<'a, 'b> { /// ``` #[cfg(any(feature = "std", test))] pub fn print_resolved(iter: PropertyIterator<'_, '_>, indent: usize) { - print_resolved_with_limits(iter, indent, 100, 1000000); + print_resolved_with_limits(iter, indent, 100, 1_000_000); } /// Print a resolved [`PropertyIterator`] with depth and item limits to prevent infinite expansion. diff --git a/src/deserializer/typedstream.rs b/src/deserializer/typedstream.rs index 3bf7146..b6a6fe5 100644 --- a/src/deserializer/typedstream.rs +++ b/src/deserializer/typedstream.rs @@ -265,9 +265,8 @@ impl<'a> TypedStreamDeserializer<'a> { } // If we did not create any new classes, just return what we found. - let first_idx = match first_new { - None => return Ok(final_parent), - Some(i) => i, + let Some(first_idx) = first_new else { + return Ok(final_parent); }; // Patch the outer-most newly created class so that it points to the From 67e648c732da0e7bb39e19ad172c1965de885230 Mon Sep 17 00:00:00 2001 From: Christopher Sardegna Date: Fri, 29 Aug 2025 11:29:44 -0700 Subject: [PATCH 2/2] Pass by value (perf++) --- src/models/types.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/types.rs b/src/models/types.rs index 7f3e723..09f9baa 100644 --- a/src/models/types.rs +++ b/src/models/types.rs @@ -75,8 +75,8 @@ pub enum Type<'a> { impl<'a> Type<'a> { /// Convert a byte to a Type enum variant #[inline] - pub(crate) fn from_byte(byte: &u8) -> Self { - match *byte { + pub(crate) fn from_byte(byte: u8) -> Self { + match byte { 0x40 => Self::Object, 0x2B => Self::Utf8String, 0x2A => Self::EmbeddedData, @@ -128,7 +128,7 @@ impl<'a> Type<'a> { } Ok(Consumed::new( - type_bytes.iter().map(Type::from_byte).collect(), + type_bytes.iter().copied().map(Type::from_byte).collect(), type_length.bytes_consumed + type_bytes.len(), )) }