File tree 1 file changed +7
-11
lines changed
1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -213,14 +213,10 @@ impl AttrTokenStream {
213
213
. into_iter ( )
214
214
}
215
215
AttrTokenTree :: Attributes ( data) => {
216
- let mut outer_attrs = Vec :: new ( ) ;
217
- let mut inner_attrs = Vec :: new ( ) ;
218
- for attr in & data. attrs {
219
- match attr. style {
220
- crate :: AttrStyle :: Outer => outer_attrs. push ( attr) ,
221
- crate :: AttrStyle :: Inner => inner_attrs. push ( attr) ,
222
- }
223
- }
216
+ let idx = data
217
+ . attrs
218
+ . partition_point ( |attr| matches ! ( attr. style, crate :: AttrStyle :: Outer ) ) ;
219
+ let ( outer_attrs, inner_attrs) = data. attrs . split_at ( idx) ;
224
220
225
221
let mut target_tokens: Vec < _ > = data
226
222
. tokens
@@ -265,10 +261,10 @@ impl AttrTokenStream {
265
261
"Failed to find trailing delimited group in: {target_tokens:?}"
266
262
) ;
267
263
}
268
- let mut flat: SmallVec < [ _ ; 1 ] > = SmallVec :: new ( ) ;
264
+ let mut flat: SmallVec < [ _ ; 1 ] > =
265
+ SmallVec :: with_capacity ( target_tokens. len ( ) + outer_attrs. len ( ) ) ;
269
266
for attr in outer_attrs {
270
- // FIXME: Make this more efficient
271
- flat. extend ( attr. tokens ( ) . 0 . clone ( ) . iter ( ) . cloned ( ) ) ;
267
+ flat. extend ( attr. tokens ( ) . 0 . iter ( ) . cloned ( ) ) ;
272
268
}
273
269
flat. extend ( target_tokens) ;
274
270
flat. into_iter ( )
You can’t perform that action at this time.
0 commit comments