perf: refactor IRuntime to use HashSet for exists_keys and improve related functions performance

This commit is contained in:
Tunglies
2025-11-22 16:25:23 +08:00
parent c82cefe80e
commit 82bed4910e
4 changed files with 68 additions and 58 deletions

View File

@@ -4,7 +4,7 @@ use anyhow::{Context as _, anyhow};
use clash_verge_logging::{Type, logging_error};
use serde_yaml_ng::Mapping;
use smartstring::alias::String;
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
/// 获取运行时配置
#[tauri::command]
@@ -31,7 +31,7 @@ pub async fn get_runtime_yaml() -> CmdResult<String> {
/// 获取运行时存在的键
#[tauri::command]
pub async fn get_runtime_exists() -> CmdResult<Vec<String>> {
pub async fn get_runtime_exists() -> CmdResult<HashSet<String>> {
Ok(Config::runtime().await.latest_arc().exists_keys.clone())
}