File tree Expand file tree Collapse file tree 7 files changed +9
-9
lines changed
crates/swc_ecma_parser/src Expand file tree Collapse file tree 7 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -910,7 +910,7 @@ impl Lexer<'_> {
910910 fn read_unicode_escape ( & mut self ) -> LexResult < Vec < Char > > {
911911 debug_assert_eq ! ( self . cur( ) , Some ( 'u' ) ) ;
912912
913- let mut chars = Vec :: new ( ) ;
913+ let mut chars = Vec :: with_capacity ( 4 ) ;
914914 let mut is_curly = false ;
915915
916916 self . bump ( ) ; // 'u'
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ impl<I: Tokens> Parser<I> {
124124 let implements = if p. input . syntax ( ) . typescript ( ) && eat ! ( p, "implements" ) {
125125 p. parse_ts_heritage_clause ( ) ?
126126 } else {
127- Vec :: new ( )
127+ Vec :: with_capacity ( 4 )
128128 } ;
129129
130130 {
@@ -333,7 +333,7 @@ impl<I: Tokens> Parser<I> {
333333 }
334334
335335 fn parse_class_body ( & mut self ) -> PResult < Vec < ClassMember > > {
336- let mut elems = Vec :: new ( ) ;
336+ let mut elems = Vec :: with_capacity ( 32 ) ;
337337 let mut has_constructor_with_body = false ;
338338 while !eof ! ( self ) && !is ! ( self , '}' ) {
339339 if eat_exact ! ( self , ';' ) {
Original file line number Diff line number Diff line change @@ -499,7 +499,7 @@ impl<I: Tokens> Parser<I> {
499499 let start = cur_pos ! ( self ) ;
500500
501501 assert_and_bump ! ( self , '[' ) ;
502- let mut elems = Vec :: new ( ) ;
502+ let mut elems = Vec :: with_capacity ( 8 ) ;
503503
504504 while !eof ! ( self ) && !is ! ( self , ']' ) {
505505 if is ! ( self , ',' ) {
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ impl<I: Tokens> Parser<I> {
2222 let mut trailing_comma = None ;
2323 assert_and_bump ! ( p, '{' ) ;
2424
25- let mut props = Vec :: new ( ) ;
25+ let mut props = Vec :: with_capacity ( 8 ) ;
2626
2727 while !eat ! ( p, '}' ) {
2828 props. push ( p. parse_object_prop ( ) ?) ;
Original file line number Diff line number Diff line change @@ -904,7 +904,7 @@ impl<'a, I: Tokens> Parser<I> {
904904 }
905905 }
906906
907- let mut decls = Vec :: new ( ) ;
907+ let mut decls = Vec :: with_capacity ( 4 ) ;
908908 let mut first = true ;
909909 while first || eat ! ( self , ',' ) {
910910 if first {
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ impl<I: Tokens> Parser<I> {
7979
8080 let mut type_only = false ;
8181 let mut phase = ImportPhase :: Evaluation ;
82- let mut specifiers = Vec :: new ( ) ;
82+ let mut specifiers = Vec :: with_capacity ( 4 ) ;
8383
8484 ' import_maybe_ident: {
8585 if is ! ( self , BindingIdent ) {
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ impl<I: Tokens> Parser<I> {
7979 {
8080 debug_assert ! ( self . input. syntax( ) . typescript( ) ) ;
8181
82- let mut buf = Vec :: new ( ) ;
82+ let mut buf = Vec :: with_capacity ( 8 ) ;
8383 while !self . is_ts_list_terminator ( kind) ? {
8484 // Skipping "parseListElement" from the TS source since that's just for error
8585 // handling.
@@ -1980,7 +1980,7 @@ impl<I: Tokens> Parser<I> {
19801980 debug_assert ! ( self . input. syntax( ) . typescript( ) ) ;
19811981
19821982 let params = self . parse_formal_params ( ) ?;
1983- let mut list = Vec :: new ( ) ;
1983+ let mut list = Vec :: with_capacity ( 4 ) ;
19841984
19851985 for param in params {
19861986 let item = match param. pat {
You can’t perform that action at this time.
0 commit comments