Skip to content

Commit

Permalink
merge bool and associated param into one Option
Browse files Browse the repository at this point in the history
replace linked parameter scope_collection + bool send_all_scopes with an
Option<ScopeCollection>
  • Loading branch information
gwen-lg committed Dec 23, 2024
1 parent 8219463 commit 51e56cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 2 additions & 3 deletions puffin/src/frame_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _;
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion puffin/src/profile_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
8 changes: 7 additions & 1 deletion puffin_http/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 51e56cf

Please sign in to comment.