File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
crates/djls-templates/src Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ impl Parser {
1717 }
1818
1919 pub fn parse ( & mut self ) -> ( Vec < Node > , Vec < ParseError > ) {
20- let mut nodelist = Vec :: new ( ) ;
21- let mut errors = Vec :: new ( ) ;
20+ let mut nodelist = Vec :: with_capacity ( self . tokens . len ( ) / 2 ) ;
21+ let mut errors = Vec :: with_capacity ( 4 ) ;
2222
2323 while !self . is_at_end ( ) {
2424 match self . next_node ( ) {
@@ -85,11 +85,15 @@ impl Parser {
8585 } ) ;
8686 } ;
8787
88- let mut parts = content_ref. split_whitespace ( ) ;
88+ let mut parts = content_ref. split_ascii_whitespace ( ) ;
8989
9090 let name = parts. next ( ) . ok_or ( ParseError :: EmptyTag ) ?. to_string ( ) ;
9191
92- let bits = parts. map ( std:: string:: ToString :: to_string) . collect ( ) ;
92+ let mut bits = Vec :: with_capacity ( parts. clone ( ) . count ( ) ) ;
93+ for part in parts {
94+ bits. push ( part. to_owned ( ) ) ;
95+ }
96+
9397 let span = token. content_span_or_fallback ( ) ;
9498
9599 Ok ( Node :: Tag { name, bits, span } )
You can’t perform that action at this time.
0 commit comments