Skip to content

Commit 90716e8

Browse files
committed
Add a way to create an EventId with multiple arguments
1 parent e778699 commit 90716e8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

measureme/src/event_id.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,17 @@ impl<'p> EventIdBuilder<'p> {
7878
StringComponent::Ref(arg),
7979
]))
8080
}
81+
82+
pub fn from_label_and_args(&self, label: StringId, args: &[StringId]) -> EventId {
83+
// The capacity is the number of args + the same number for arg separators + the label.
84+
let mut parts = Vec::with_capacity(args.len() * 2 + 1);
85+
parts.push(StringComponent::Ref(label));
86+
87+
for arg in args {
88+
parts.push(StringComponent::Value(SEPARATOR_BYTE));
89+
parts.push(StringComponent::Ref(*arg));
90+
}
91+
92+
EventId(self.profiler.alloc_string(&parts[..]))
93+
}
8194
}

0 commit comments

Comments
 (0)