From e1cd40a7fb0f8dd83714f706a6e12324d239d3a6 Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Thu, 30 Sep 2021 21:36:20 +0200 Subject: [PATCH] Fix some typos and change HashSet to FxHashSet --- boa/src/syntax/parser/expression/primary/mod.rs | 2 +- .../parser/expression/primary/object_initializer/mod.rs | 6 +++--- boa/src/syntax/parser/function/mod.rs | 5 +++-- boa/src/syntax/parser/statement/mod.rs | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/boa/src/syntax/parser/expression/primary/mod.rs b/boa/src/syntax/parser/expression/primary/mod.rs index c680e244c21..f66d1940b2e 100644 --- a/boa/src/syntax/parser/expression/primary/mod.rs +++ b/boa/src/syntax/parser/expression/primary/mod.rs @@ -130,7 +130,7 @@ where } Ok(Identifier::from("yield").into()) } - TokenKind::Keyword(Keyword::Await) if self.allow_yield.0 => { + TokenKind::Keyword(Keyword::Await) if self.allow_await.0 => { // Early Error: It is a Syntax Error if this production has an [Await] parameter and StringValue of Identifier is "await". Err(ParseError::general( "Unexpected identifier", diff --git a/boa/src/syntax/parser/expression/primary/object_initializer/mod.rs b/boa/src/syntax/parser/expression/primary/object_initializer/mod.rs index d10cf0c77ec..041d713cafd 100644 --- a/boa/src/syntax/parser/expression/primary/object_initializer/mod.rs +++ b/boa/src/syntax/parser/expression/primary/object_initializer/mod.rs @@ -267,12 +267,12 @@ where return Ok(node::PropertyDefinition::property(property_name, value)); } - let ordinary = cursor.peek(0)?.ok_or(ParseError::AbruptEnd)?.kind() + let ordinary_method = cursor.peek(0)?.ok_or(ParseError::AbruptEnd)?.kind() == &TokenKind::Punctuator(Punctuator::OpenParen); match property_name { // MethodDefinition[?Yield, ?Await] -> get ClassElementName[?Yield, ?Await] ( ) { FunctionBody[~Yield, ~Await] } - node::PropertyName::Literal(str) if str.as_ref() == "get" && !ordinary => { + node::PropertyName::Literal(str) if str.as_ref() == "get" && !ordinary_method => { property_name = PropertyName::new(self.allow_yield, self.allow_await).parse(cursor)?; @@ -302,7 +302,7 @@ where )) } // MethodDefinition[?Yield, ?Await] -> set ClassElementName[?Yield, ?Await] ( PropertySetParameterList ) { FunctionBody[~Yield, ~Await] } - node::PropertyName::Literal(str) if str.as_ref() == "set" && !ordinary => { + node::PropertyName::Literal(str) if str.as_ref() == "set" && !ordinary_method => { property_name = PropertyName::new(self.allow_yield, self.allow_await).parse(cursor)?; diff --git a/boa/src/syntax/parser/function/mod.rs b/boa/src/syntax/parser/function/mod.rs index ac47d541dd6..40887c1cabf 100644 --- a/boa/src/syntax/parser/function/mod.rs +++ b/boa/src/syntax/parser/function/mod.rs @@ -22,7 +22,8 @@ use crate::{ }, BoaProfiler, }; -use std::{collections::HashSet, io::Read}; +use rustc_hash::FxHashSet; +use std::io::Read; /// Intermediate type for a list of FormalParameters with some meta information. pub(in crate::syntax::parser) struct FormalParameterList { @@ -83,7 +84,7 @@ where } let start_position = next_token.span().start(); - let mut parameter_names = HashSet::new(); + let mut parameter_names = FxHashSet::default(); loop { let mut rest_param = false; diff --git a/boa/src/syntax/parser/statement/mod.rs b/boa/src/syntax/parser/statement/mod.rs index df34a8fc0f3..1e9447c14a3 100644 --- a/boa/src/syntax/parser/statement/mod.rs +++ b/boa/src/syntax/parser/statement/mod.rs @@ -537,7 +537,7 @@ where Ok("yield".into()) } } - TokenKind::Keyword(Keyword::Await) if self.allow_yield.0 => { + TokenKind::Keyword(Keyword::Await) if self.allow_await.0 => { // Early Error: It is a Syntax Error if this production has an [Await] parameter and StringValue of Identifier is "await". Err(ParseError::general( "Unexpected identifier",