Skip to content

Commit ff33e7a

Browse files
committed
perf: cow
1 parent 8182e35 commit ff33e7a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crates/core/src/hast_to_swc_ast/decode_xml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub fn decode_xml(s: &str) -> String {
22
let bytes = s.as_bytes();
33

4-
let mut ret = String::new();
4+
let mut ret = String::with_capacity(s.len());
55
let mut cur_idx = 0;
66
let mut last_idx = 0;
77

crates/core/src/hast_to_swc_ast/string_to_object_style.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
use std::borrow::Cow;
2+
13
use lazy_static::lazy_static;
24
use regex::{Captures, Regex};
35
use swc_core::{common::DUMMY_SP, ecma::ast::*};
46

57
use super::util::*;
68

7-
pub fn hyphen_to_camel_case(s: &str) -> String {
9+
pub fn hyphen_to_camel_case(s: &str) -> Cow<str> {
810
lazy_static! {
911
static ref HYPHEN_REGEX: Regex = Regex::new(r#"-(.)"#).unwrap();
1012
}
11-
HYPHEN_REGEX
12-
.replace_all(s, |caps: &Captures| caps[1].to_uppercase())
13-
.into()
13+
HYPHEN_REGEX.replace_all(s, |caps: &Captures| caps[1].to_uppercase())
1414
}
1515

1616
// Format style key into JSX style object key.

0 commit comments

Comments
 (0)