From 346080aad294a98896a134702ca9da2a1e753b60 Mon Sep 17 00:00:00 2001 From: Will Lillis Date: Sat, 26 Jul 2025 20:07:45 -0400 Subject: [PATCH] refactor(loader): replace `replace_dashes_with_underscores` with rust std lib --- crates/loader/src/loader.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/crates/loader/src/loader.rs b/crates/loader/src/loader.rs index fad997db..5156158f 100644 --- a/crates/loader/src/loader.rs +++ b/crates/loader/src/loader.rs @@ -723,10 +723,7 @@ impl Loader { pub fn load_language_at_path_with_name(&self, mut config: CompileConfig) -> Result { let mut lib_name = config.name.to_string(); - let language_fn_name = format!( - "tree_sitter_{}", - replace_dashes_with_underscores(&config.name) - ); + let language_fn_name = format!("tree_sitter_{}", config.name.replace('-', "_")); if self.debug_build { lib_name.push_str(".debug._"); } @@ -1714,15 +1711,3 @@ fn needs_recompile(lib_path: &Path, paths_to_check: &[PathBuf]) -> Result fn mtime(path: &Path) -> Result { Ok(fs::metadata(path)?.modified()?) } - -fn replace_dashes_with_underscores(name: &str) -> String { - let mut result = String::with_capacity(name.len()); - for c in name.chars() { - if c == '-' { - result.push('_'); - } else { - result.push(c); - } - } - result -}