Skip to content

Commit 5cde29b

Browse files
committed
perf(linter): replace phf_set with array in react/void-dom-elements-no-children (oxc-project#10425)
Related to oxc-project#10076
1 parent 7ef1e0d commit 5cde29b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

crates/oxc_linter/src/rules/react/void_dom_elements_no_children.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use oxc_ast::{
88
use oxc_diagnostics::OxcDiagnostic;
99
use oxc_macros::declare_oxc_lint;
1010
use oxc_span::Span;
11-
use phf::phf_set;
1211

1312
use crate::{
1413
AstNode,
@@ -61,13 +60,13 @@ declare_oxc_lint!(
6160
correctness
6261
);
6362

64-
const VOID_DOM_ELEMENTS: phf::Set<&'static str> = phf_set![
63+
const VOID_DOM_ELEMENTS: [&str; 16] = [
6564
"area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "menuitem",
6665
"meta", "param", "source", "track", "wbr",
6766
];
6867

69-
pub fn is_void_dom_element(element_name: &str) -> bool {
70-
VOID_DOM_ELEMENTS.contains(element_name)
68+
pub fn is_not_void_dom_element(element_name: &str) -> bool {
69+
VOID_DOM_ELEMENTS.binary_search(&element_name).is_err()
7170
}
7271

7372
impl Rule for VoidDomElementsNoChildren {
@@ -79,7 +78,7 @@ impl Rule for VoidDomElementsNoChildren {
7978
return;
8079
};
8180

82-
if !is_void_dom_element(&identifier.name) {
81+
if is_not_void_dom_element(&identifier.name) {
8382
return;
8483
}
8584

@@ -115,7 +114,7 @@ impl Rule for VoidDomElementsNoChildren {
115114
return;
116115
};
117116

118-
if !is_void_dom_element(element_name.value.as_str()) {
117+
if is_not_void_dom_element(element_name.value.as_str()) {
119118
return;
120119
}
121120

0 commit comments

Comments
 (0)