From 51e56cff24e1fcc9db128a9b8a35f3a653047a00 Mon Sep 17 00:00:00 2001 From: Gwen Lg Date: Sun, 22 Dec 2024 19:41:42 +0100 Subject: [PATCH] merge bool and associated param into one Option replace linked parameter scope_collection + bool send_all_scopes with an Option --- puffin/src/frame_data.rs | 5 ++--- puffin/src/profile_view.rs | 2 +- puffin_http/src/server.rs | 8 +++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/puffin/src/frame_data.rs b/puffin/src/frame_data.rs index ed29d188..dac12650 100644 --- a/puffin/src/frame_data.rs +++ b/puffin/src/frame_data.rs @@ -561,8 +561,7 @@ impl FrameData { #[cfg(feature = "serialization")] pub fn write_into( &self, - scope_collection: &crate::ScopeCollection, - send_all_scopes: bool, + scope_collection: Option<&crate::ScopeCollection>, write: &mut impl std::io::Write, ) -> anyhow::Result<()> { use bincode::Options as _; @@ -582,7 +581,7 @@ impl FrameData { write.write_u8(packed_streams.compression_kind as u8)?; write.write_all(&packed_streams.bytes)?; - let to_serialize_scopes: Vec<_> = if send_all_scopes { + let to_serialize_scopes: Vec<_> = if let Some(scope_collection) = scope_collection { scope_collection.scopes_by_id().values().cloned().collect() } else { self.scope_delta.clone() diff --git a/puffin/src/profile_view.rs b/puffin/src/profile_view.rs index 7882f3c4..07c64ab6 100644 --- a/puffin/src/profile_view.rs +++ b/puffin/src/profile_view.rs @@ -229,7 +229,7 @@ impl FrameView { write.write_all(b"PUF0")?; for frame in self.all_uniq() { - frame.write_into(&self.scope_collection, false, write)?; + frame.write_into(None, write)?; } Ok(()) } diff --git a/puffin_http/src/server.rs b/puffin_http/src/server.rs index e6fa39a6..3d73cfc1 100644 --- a/puffin_http/src/server.rs +++ b/puffin_http/src/server.rs @@ -382,8 +382,14 @@ impl PuffinServerImpl { .write_all(&crate::PROTOCOL_VERSION.to_le_bytes()) .unwrap(); + let scope_collection = if self.send_all_scopes { + Some(&self.scope_collection) + } else { + None + }; + frame - .write_into(&self.scope_collection, self.send_all_scopes, &mut packet) + .write_into(scope_collection, &mut packet) .context("Encode puffin frame")?; self.send_all_scopes = false;