From 4441c7fa502cb6a9d1ee4aa1f64d70d4aa51016b Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 23 Nov 2021 13:00:41 +0800 Subject: [PATCH] Do not go through JsWord->&[u8]->&str. --- .../swc/crates/core/src/react_remove_properties.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/next/build/swc/crates/core/src/react_remove_properties.rs b/packages/next/build/swc/crates/core/src/react_remove_properties.rs index d437a94f17b2b3..b6a051fc9d2a0a 100644 --- a/packages/next/build/swc/crates/core/src/react_remove_properties.rs +++ b/packages/next/build/swc/crates/core/src/react_remove_properties.rs @@ -30,12 +30,8 @@ struct RemoveProperties { } impl RemoveProperties { - fn should_remove_property(&self, name: &[u8]) -> bool { - if let Ok(name) = std::str::from_utf8(name) { - self.properties.iter().any(|p| p.is_match(name)) - } else { - false - } + fn should_remove_property(&self, name: &str) -> bool { + self.properties.iter().any(|p| p.is_match(name)) } } @@ -47,7 +43,7 @@ impl Fold for RemoveProperties { JSXAttrOrSpread::JSXAttr(JSXAttr { name: JSXAttrName::Ident(ident), .. - }) if self.should_remove_property(ident.sym.as_bytes()) => false, + }) if self.should_remove_property(ident.sym.as_ref()) => false, _ => true, }); el