refactor(es/parser): Remove duplicate (#4750)

This commit is contained in:
Donny/강동윤 2022-05-23 18:42:29 +09:00 committed by GitHub
parent 4d606effdf
commit b7a195a1cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 17 deletions

1
Cargo.lock generated
View File

@ -3470,7 +3470,6 @@ dependencies = [
"testing",
"tracing",
"typed-arena",
"unicode-id",
"walkdir",
]

View File

@ -150,6 +150,7 @@ impl Ident {
}
/// Returns true if `c` is a valid character for an identifier start.
#[inline]
pub fn is_valid_start(c: char) -> bool {
c == '$' || c == '_' || c.is_ascii_alphabetic() || {
if c.is_ascii() {
@ -162,6 +163,7 @@ impl Ident {
/// Returns true if `c` is a valid character for an identifier part after
/// start.
#[inline]
pub fn is_valid_continue(c: char) -> bool {
c == '$' || c == '_' || c == '\u{200c}' || c == '\u{200d}' || c.is_ascii_alphanumeric() || {
if c.is_ascii() {

View File

@ -36,7 +36,6 @@ swc_ecma_ast = { version = "0.78.0", path = "../swc_ecma_ast" }
swc_ecma_visit = { version = "0.64.0", path = "../swc_ecma_visit", optional = true }
tracing = "0.1.32"
typed-arena = "2.0.1"
unicode-id = "0.3"
[dev-dependencies]
criterion = "0.3"

View File

@ -8,8 +8,8 @@ use swc_common::{
comments::{Comment, CommentKind},
BytePos, Span, SyntaxContext,
};
use swc_ecma_ast::Ident;
use tracing::warn;
use unicode_id::UnicodeID;
use super::{comments_buffer::BufferedComment, input::Input, Char, LexResult, Lexer};
use crate::{
@ -351,13 +351,7 @@ pub trait CharExt: Copy {
Some(c) => c,
None => return false,
};
c == '$' || c == '_' || c.is_ascii_alphabetic() || {
if c.is_ascii() {
false
} else {
UnicodeID::is_id_start(c)
}
}
Ident::is_valid_start(c)
}
/// Test whether a given character is part of an identifier.
@ -367,13 +361,7 @@ pub trait CharExt: Copy {
Some(c) => c,
None => return false,
};
c == '$' || c == '_' || c == '\u{200c}' || c == '\u{200d}' || c.is_ascii_alphanumeric() || {
if c.is_ascii() {
false
} else {
UnicodeID::is_id_continue(c)
}
}
Ident::is_valid_continue(c)
}
/// See https://tc39.github.io/ecma262/#sec-line-terminators