refactor(i18n): optimize translation handling with Arc<str> for better memory efficiency

refactor(tray): change menu text storage to use Arc<str> for improved performance
refactor(service): utilize SmartString for error messages to enhance memory management
This commit is contained in:
Tunglies
2025-10-28 00:26:20 +08:00
parent a9eb512f20
commit f39436f1d0
4 changed files with 36 additions and 23 deletions

View File

@@ -3,6 +3,7 @@ use crate::{
core::service::{self, SERVICE_MANAGER, ServiceStatus},
utils::i18n::t,
};
use smartstring::SmartString;
async fn execute_service_operation_sync(status: ServiceStatus, op_type: &str) -> CmdResult {
if let Err(e) = SERVICE_MANAGER
@@ -12,7 +13,7 @@ async fn execute_service_operation_sync(status: ServiceStatus, op_type: &str) ->
.await
{
let emsg = format!("{} Service failed: {}", op_type, e);
return Err(t(emsg.as_str()).await);
return Err(SmartString::from(&*t(emsg.as_str()).await));
}
Ok(())
}