File tree 3 files changed +9
-10
lines changed
3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -482,9 +482,10 @@ impl PartialEq for InstrumentationScope {
482
482
self . name == other. name
483
483
&& self . version == other. version
484
484
&& self . schema_url == other. schema_url
485
+ && self . attributes . len ( ) == other. attributes . len ( )
485
486
&& {
486
- let mut self_attrs = self . attributes . clone ( ) ;
487
- let mut other_attrs = other. attributes . clone ( ) ;
487
+ let mut self_attrs = Vec :: from_iter ( & self . attributes ) ;
488
+ let mut other_attrs = Vec :: from_iter ( & other. attributes ) ;
488
489
self_attrs. sort_unstable_by ( |a, b| a. key . cmp ( & b. key ) ) ;
489
490
other_attrs. sort_unstable_by ( |a, b| a. key . cmp ( & b. key ) ) ;
490
491
self_attrs == other_attrs
@@ -499,7 +500,7 @@ impl hash::Hash for InstrumentationScope {
499
500
self . name . hash ( state) ;
500
501
self . version . hash ( state) ;
501
502
self . schema_url . hash ( state) ;
502
- let mut sorted_attrs = self . attributes . clone ( ) ;
503
+ let mut sorted_attrs = Vec :: from_iter ( & self . attributes ) ;
503
504
sorted_attrs. sort_unstable_by ( |a, b| a. key . cmp ( & b. key ) ) ;
504
505
for attribute in sorted_attrs {
505
506
attribute. hash ( state) ;
Original file line number Diff line number Diff line change @@ -77,9 +77,7 @@ impl TextMapCompositePropagator {
77
77
pub fn new ( propagators : Vec < Box < dyn TextMapPropagator + Send + Sync > > ) -> Self {
78
78
let mut fields = HashSet :: new ( ) ;
79
79
for propagator in & propagators {
80
- for field in propagator. fields ( ) {
81
- fields. insert ( field. to_string ( ) ) ;
82
- }
80
+ fields. extend ( propagator. fields ( ) . map ( ToString :: to_string) ) ;
83
81
}
84
82
85
83
TextMapCompositePropagator {
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ impl TraceState {
134
134
return Err ( TraceStateError :: Value ( value) ) ;
135
135
}
136
136
137
- let mut trace_state = self . delete_from_deque ( key. clone ( ) ) ;
137
+ let mut trace_state = self . delete_from_deque ( & key) ;
138
138
let kvs = trace_state. 0 . get_or_insert ( VecDeque :: with_capacity ( 1 ) ) ;
139
139
140
140
kvs. push_front ( ( key, value) ) ;
@@ -155,14 +155,14 @@ impl TraceState {
155
155
return Err ( TraceStateError :: Key ( key) ) ;
156
156
}
157
157
158
- Ok ( self . delete_from_deque ( key) )
158
+ Ok ( self . delete_from_deque ( & key) )
159
159
}
160
160
161
161
/// Delete key from trace state's deque. The key MUST be valid
162
- fn delete_from_deque ( & self , key : String ) -> TraceState {
162
+ fn delete_from_deque ( & self , key : & str ) -> TraceState {
163
163
let mut owned = self . clone ( ) ;
164
164
if let Some ( kvs) = owned. 0 . as_mut ( ) {
165
- if let Some ( index) = kvs. iter ( ) . position ( |x| * x. 0 == * key) {
165
+ if let Some ( index) = kvs. iter ( ) . position ( |x| x. 0 == key) {
166
166
kvs. remove ( index) ;
167
167
}
168
168
}
You can’t perform that action at this time.
0 commit comments