@@ -16,6 +16,8 @@ once_cell::sync::Lazy::new(|| {
16
16
data
17
17
} ) ;
18
18
19
+ static BH : once_cell:: sync:: Lazy < RandomState > = once_cell:: sync:: Lazy :: new ( || { RandomState :: new ( ) } ) ;
20
+
19
21
pub ( crate ) static EVENT_METADATA : once_cell:: sync:: Lazy <
20
22
Box < [ crate :: _details:: ParsedEventMetadata ] > ,
21
23
> = once_cell:: sync:: Lazy :: new ( || {
@@ -63,12 +65,11 @@ pub(crate) static EVENT_METADATA: once_cell::sync::Lazy<
63
65
next_pos += 1 ;
64
66
}
65
67
66
- let mut map: Box < [ core:: mem:: MaybeUninit < crate :: _details:: ParsedEventMetadata > ] > = Box :: new_uninit_slice ( good_pos) ;
67
- let bh = RandomState :: new ( ) ;
68
+ let mut map: Box < [ core:: mem:: MaybeUninit < crate :: _details:: ParsedEventMetadata > ] > = Box :: new_uninit_slice ( good_pos + 1 ) ;
68
69
next_pos = 0 ;
69
- while next_pos < good_pos {
70
+ while next_pos <= good_pos {
70
71
let next = & * events_slice[ next_pos] ;
71
- map[ next_pos] . as_mut_ptr ( ) . write ( crate :: _details:: ParsedEventMetadata { identity_hash : bh . hash_one ( & next. identity ) , kw : next. kw , event_tag : next. event_tag } ) ;
72
+ map[ next_pos] . as_mut_ptr ( ) . write ( crate :: _details:: ParsedEventMetadata { identity_hash : BH . hash_one ( & next. identity ) , kw : next. kw , event_tag : next. event_tag } ) ;
72
73
next_pos += 1 ;
73
74
}
74
75
let mut sorted = map. assume_init ( ) ;
@@ -98,8 +99,7 @@ impl core::cmp::Ord for crate::_details::ParsedEventMetadata {
98
99
}
99
100
100
101
pub ( crate ) fn get_event_metadata ( id : & tracing:: callsite:: Identifier ) -> Option < & ' static crate :: _details:: ParsedEventMetadata > {
101
- let bh = RandomState :: new ( ) ;
102
- let hash = bh. hash_one ( id) ;
102
+ let hash = BH . hash_one ( id) ;
103
103
let etw_meta = EVENT_METADATA . binary_search_by_key ( & hash, |m| { m. identity_hash } ) ;
104
104
match etw_meta {
105
105
Ok ( idx) => Some ( & EVENT_METADATA [ idx] ) ,
0 commit comments