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

@@ -39,11 +39,11 @@ async fn get_bypass() -> String {
};
let custom_bypass = match res {
Some(bypass) => bypass,
None => "".to_string(),
None => "".into(),
};
if custom_bypass.is_empty() {
DEFAULT_BYPASS.to_string()
DEFAULT_BYPASS.into()
} else if use_default {
format!("{DEFAULT_BYPASS},{custom_bypass}")
} else {
@@ -180,11 +180,11 @@ impl Sysopt {
let args = if pac_enable {
let address = format!("http://{proxy_host}:{pac_port}/commands/pac");
vec!["pac".to_string(), address]
vec!["pac".into(), address]
} else {
let address = format!("{proxy_host}:{port}");
let bypass = get_bypass().await;
vec!["global".to_string(), address, bypass]
vec!["global".into(), address, bypass]
};
execute_sysproxy_command(args).await?;
@@ -208,7 +208,7 @@ impl Sysopt {
log::warn!(target: "app", "重置代理时获取自动代理配置失败: {e}, 使用默认配置");
Autoproxy {
enable: false,
url: "".to_string(),
url: "".into(),
}
}
};
@@ -220,7 +220,7 @@ impl Sysopt {
#[cfg(target_os = "windows")]
{
execute_sysproxy_command(vec!["set".to_string(), "1".to_string()]).await?;
execute_sysproxy_command(vec!["set".into(), "1".into()]).await?;
}
Ok(())