@@ -81,18 +81,17 @@ static EVENT_METADATA: LazyLock<Box<[ParsedEventMetadata]>> = LazyLock::new(|| {
81
81
82
82
let bh = FnvHasher :: default ( ) ;
83
83
84
- let mut map : Box < [ core :: mem :: MaybeUninit < ParsedEventMetadata > ] > = Box :: new_uninit_slice ( good_pos + 1 ) ;
84
+ let mut vec = Vec :: with_capacity ( good_pos + 1 ) ;
85
85
next_pos = 0 ;
86
86
while next_pos <= good_pos {
87
87
// SAFETY The above code as already validated that events_slice[0..good_pos] are non-null pointers
88
88
let next = unsafe { & * events_slice[ next_pos] } ;
89
89
let identity_hash = bh. hash_one ( & next. identity ) ;
90
- // SAFETY The pointer being written to is valid (we just allocated it above) and aligned (it was allocated with the same type as being written)
91
- unsafe { map[ next_pos] . as_mut_ptr ( ) . write ( ParsedEventMetadata { identity_hash, meta : next } ) } ;
90
+ vec. push ( ParsedEventMetadata { identity_hash, meta : next } ) ;
92
91
next_pos += 1 ;
93
92
}
94
- // SAFETY We've explicitly initialized all the values now
95
- let mut sorted = unsafe { map . assume_init ( ) } ;
93
+
94
+ let mut sorted = vec . into_boxed_slice ( ) ;
96
95
sorted. sort_unstable_by ( |a, b| b. cmp ( a) ) ;
97
96
sorted
98
97
} ) ;
@@ -111,23 +110,10 @@ impl core::cmp::PartialOrd for ParsedEventMetadata {
111
110
}
112
111
}
113
112
113
+ // Order by hash only
114
114
impl core:: cmp:: Ord for ParsedEventMetadata {
115
115
fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
116
- match self . identity_hash . cmp ( & other. identity_hash ) {
117
- cmp:: Ordering :: Equal => {
118
- match self . meta . identity == other. meta . identity {
119
- true => cmp:: Ordering :: Equal ,
120
- false => {
121
- // We need to do *something* to sort two different callsites that hit a hash collision.
122
- // TODO: This only works when comparing the static entries generated by the logging macros.
123
- let lhs = & self . meta . identity as * const tracing_core:: callsite:: Identifier as usize ;
124
- let rhs = & other. meta . identity as * const tracing_core:: callsite:: Identifier as usize ;
125
- lhs. cmp ( & rhs)
126
- }
127
- }
128
- } ,
129
- x => x
130
- }
116
+ self . identity_hash . cmp ( & other. identity_hash )
131
117
}
132
118
}
133
119
@@ -179,7 +165,7 @@ pub(crate) fn event_metadata() -> impl Iterator<Item = <EventMetadataEnumerator
179
165
EventMetadataEnumerator { current_index : 0 }
180
166
}
181
167
182
- // Only one test function can be compiled into the module at a time, since the statics they produce are global
168
+ // Only one test function can be compiled into the module at a time, since the statics the macro produces are global
183
169
#[ cfg( test) ]
184
170
mod test {
185
171
use tracing:: Level ;
0 commit comments