Refactor string handling to use into() instead of to_string() for improved performance and consistency across the codebase. This change affects various modules including app.rs, clash.rs, config.rs, core.rs, service.rs, and others, ensuring that string conversions are streamlined and more idiomatic.

This commit is contained in:
Tunglies
2025-10-14 09:24:39 +08:00
parent 44eb781060
commit 924e7d1022
22 changed files with 167 additions and 161 deletions

View File

@@ -35,7 +35,7 @@ impl IClashTemp {
if let Some(Value::String(s)) = map.get_mut("secret")
&& s.is_empty()
{
*s = "set-your-secret".to_string();
*s = "set-your-secret".into();
}
Self(Self::guard(map))
}
@@ -323,10 +323,10 @@ impl IClashTemp {
// 总是使用当前的 IPC 路径,确保配置文件与运行时路径一致
ipc_path()
.ok()
.and_then(|path| path_to_str(&path).ok().map(|s| s.to_string()))
.and_then(|path| path_to_str(&path).ok().map(|s| s.into()))
.unwrap_or_else(|| {
log::error!(target: "app", "Failed to get IPC path, using default");
"127.0.0.1:9090".to_string()
"127.0.0.1:9090".into()
})
}
}