File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -213,14 +213,10 @@ impl AttrTokenStream {
213213 . into_iter ( )
214214 }
215215 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) ;
224220
225221 let mut target_tokens: Vec < _ > = data
226222 . tokens
@@ -265,10 +261,10 @@ impl AttrTokenStream {
265261 "Failed to find trailing delimited group in: {target_tokens:?}"
266262 ) ;
267263 }
268- let mut flat: SmallVec < [ _ ; 1 ] > = SmallVec :: new ( ) ;
264+ let mut flat: SmallVec < [ _ ; 1 ] > =
265+ SmallVec :: with_capacity ( target_tokens. len ( ) + outer_attrs. len ( ) ) ;
269266 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 ( ) ) ;
272268 }
273269 flat. extend ( target_tokens) ;
274270 flat. into_iter ( )
You can’t perform that action at this time.
0 commit comments