File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -13,5 +13,6 @@ repository = "https://github.com/rust-lang/measureme"
13
13
travis-ci = { repository = " rust-lang/measureme" }
14
14
15
15
[dependencies ]
16
- rustc-hash = " 1.0.1"
17
16
parking_lot = " 0.11.0"
17
+ rustc-hash = " 1.0.1"
18
+ smallvec = " 1.0"
Original file line number Diff line number Diff line change
1
+ use smallvec:: SmallVec ;
2
+
1
3
use crate :: { Profiler , StringComponent , StringId } ;
2
4
3
5
/// Event IDs are strings conforming to the following grammar:
@@ -78,4 +80,18 @@ impl<'p> EventIdBuilder<'p> {
78
80
StringComponent :: Ref ( arg) ,
79
81
] ) )
80
82
}
83
+
84
+ pub fn from_label_and_args ( & self , label : StringId , args : & [ StringId ] ) -> EventId {
85
+ // Store up to 7 components on the stack: 1 label + 3 arguments + 3 argument separators
86
+ let mut parts = SmallVec :: < [ StringComponent ; 7 ] > :: with_capacity ( 1 + args. len ( ) * 2 ) ;
87
+
88
+ parts. push ( StringComponent :: Ref ( label) ) ;
89
+
90
+ for arg in args {
91
+ parts. push ( StringComponent :: Value ( SEPARATOR_BYTE ) ) ;
92
+ parts. push ( StringComponent :: Ref ( * arg) ) ;
93
+ }
94
+
95
+ EventId ( self . profiler . alloc_string ( & parts[ ..] ) )
96
+ }
81
97
}
You can’t perform that action at this time.
0 commit comments