Skip to content

Commit

Permalink
perf: cow
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Sep 21, 2024
1 parent 8182e35 commit ff33e7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/core/src/hast_to_swc_ast/decode_xml.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub fn decode_xml(s: &str) -> String {
let bytes = s.as_bytes();

let mut ret = String::new();
let mut ret = String::with_capacity(s.len());
let mut cur_idx = 0;
let mut last_idx = 0;

Expand Down
8 changes: 4 additions & 4 deletions crates/core/src/hast_to_swc_ast/string_to_object_style.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use std::borrow::Cow;

use lazy_static::lazy_static;
use regex::{Captures, Regex};
use swc_core::{common::DUMMY_SP, ecma::ast::*};

use super::util::*;

pub fn hyphen_to_camel_case(s: &str) -> String {
pub fn hyphen_to_camel_case(s: &str) -> Cow<str> {
lazy_static! {
static ref HYPHEN_REGEX: Regex = Regex::new(r#"-(.)"#).unwrap();
}
HYPHEN_REGEX
.replace_all(s, |caps: &Captures| caps[1].to_uppercase())
.into()
HYPHEN_REGEX.replace_all(s, |caps: &Captures| caps[1].to_uppercase())
}

// Format style key into JSX style object key.
Expand Down

0 comments on commit ff33e7a

Please sign in to comment.