File tree 7 files changed +9
-9
lines changed
crates/swc_ecma_parser/src
7 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -910,7 +910,7 @@ impl Lexer<'_> {
910
910
fn read_unicode_escape ( & mut self ) -> LexResult < Vec < Char > > {
911
911
debug_assert_eq ! ( self . cur( ) , Some ( 'u' ) ) ;
912
912
913
- let mut chars = Vec :: new ( ) ;
913
+ let mut chars = Vec :: with_capacity ( 4 ) ;
914
914
let mut is_curly = false ;
915
915
916
916
self . bump ( ) ; // 'u'
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ impl<I: Tokens> Parser<I> {
124
124
let implements = if p. input . syntax ( ) . typescript ( ) && eat ! ( p, "implements" ) {
125
125
p. parse_ts_heritage_clause ( ) ?
126
126
} else {
127
- Vec :: new ( )
127
+ Vec :: with_capacity ( 4 )
128
128
} ;
129
129
130
130
{
@@ -333,7 +333,7 @@ impl<I: Tokens> Parser<I> {
333
333
}
334
334
335
335
fn parse_class_body ( & mut self ) -> PResult < Vec < ClassMember > > {
336
- let mut elems = Vec :: new ( ) ;
336
+ let mut elems = Vec :: with_capacity ( 32 ) ;
337
337
let mut has_constructor_with_body = false ;
338
338
while !eof ! ( self ) && !is ! ( self , '}' ) {
339
339
if eat_exact ! ( self , ';' ) {
Original file line number Diff line number Diff line change @@ -499,7 +499,7 @@ impl<I: Tokens> Parser<I> {
499
499
let start = cur_pos ! ( self ) ;
500
500
501
501
assert_and_bump ! ( self , '[' ) ;
502
- let mut elems = Vec :: new ( ) ;
502
+ let mut elems = Vec :: with_capacity ( 8 ) ;
503
503
504
504
while !eof ! ( self ) && !is ! ( self , ']' ) {
505
505
if is ! ( self , ',' ) {
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ impl<I: Tokens> Parser<I> {
22
22
let mut trailing_comma = None ;
23
23
assert_and_bump ! ( p, '{' ) ;
24
24
25
- let mut props = Vec :: new ( ) ;
25
+ let mut props = Vec :: with_capacity ( 8 ) ;
26
26
27
27
while !eat ! ( p, '}' ) {
28
28
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> {
904
904
}
905
905
}
906
906
907
- let mut decls = Vec :: new ( ) ;
907
+ let mut decls = Vec :: with_capacity ( 4 ) ;
908
908
let mut first = true ;
909
909
while first || eat ! ( self , ',' ) {
910
910
if first {
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ impl<I: Tokens> Parser<I> {
79
79
80
80
let mut type_only = false ;
81
81
let mut phase = ImportPhase :: Evaluation ;
82
- let mut specifiers = Vec :: new ( ) ;
82
+ let mut specifiers = Vec :: with_capacity ( 4 ) ;
83
83
84
84
' import_maybe_ident: {
85
85
if is ! ( self , BindingIdent ) {
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ impl<I: Tokens> Parser<I> {
79
79
{
80
80
debug_assert ! ( self . input. syntax( ) . typescript( ) ) ;
81
81
82
- let mut buf = Vec :: new ( ) ;
82
+ let mut buf = Vec :: with_capacity ( 8 ) ;
83
83
while !self . is_ts_list_terminator ( kind) ? {
84
84
// Skipping "parseListElement" from the TS source since that's just for error
85
85
// handling.
@@ -1980,7 +1980,7 @@ impl<I: Tokens> Parser<I> {
1980
1980
debug_assert ! ( self . input. syntax( ) . typescript( ) ) ;
1981
1981
1982
1982
let params = self . parse_formal_params ( ) ?;
1983
- let mut list = Vec :: new ( ) ;
1983
+ let mut list = Vec :: with_capacity ( 4 ) ;
1984
1984
1985
1985
for param in params {
1986
1986
let item = match param. pat {
You can’t perform that action at this time.
0 commit comments