Skip to content

Commit 5e14fe9

Browse files
committedMar 27, 2025·
perf(linter): inline PRE_DEFINE_VAR and use array format (#10079)
Related to #10076
1 parent da6336c commit 5e14fe9

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed
 

Diff for: ‎crates/oxc_linter/src/globals.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
use phf::{Map, phf_map, phf_set};
2-
3-
pub const PRE_DEFINE_VAR: Map<&'static str, bool> = phf_map! {
4-
"undefined" => false,
5-
"Infinity" => false,
6-
"NaN" => false,
7-
"eval" => false,
8-
"arguments" => false,
9-
};
1+
use phf::phf_set;
102

113
pub const GLOBAL_OBJECT_NAMES: phf::Set<&'static str> = phf_set! {
124
"global",

Diff for: ‎crates/oxc_linter/src/rules/eslint/no_shadow_restricted_names.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use oxc_macros::declare_oxc_lint;
44
use oxc_span::Span;
55
use oxc_syntax::symbol::SymbolId;
66

7-
use crate::{context::LintContext, globals::PRE_DEFINE_VAR, rule::Rule};
7+
use crate::{context::LintContext, rule::Rule};
8+
9+
const PRE_DEFINE_VAR: [&str; 5] = ["undefined", "Infinity", "NaN", "eval", "arguments"];
810

911
fn no_shadow_restricted_names_diagnostic(shadowed_name: &str, span: Span) -> OxcDiagnostic {
1012
OxcDiagnostic::warn("Shadowing of global properties such as 'undefined' is not allowed.")
@@ -79,7 +81,7 @@ impl Rule for NoShadowRestrictedNames {
7981
fn run_on_symbol(&self, symbol_id: SymbolId, ctx: &LintContext<'_>) {
8082
let name = ctx.scoping().symbol_name(symbol_id);
8183

82-
if !PRE_DEFINE_VAR.contains_key(name) {
84+
if !PRE_DEFINE_VAR.contains(&name) {
8385
return;
8486
}
8587

0 commit comments

Comments
 (0)
Please sign in to comment.