mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-26 22:22:13 +08:00
* perf(draft): optimize memory layout by removing double indirection - Replace `Arc<Box<T>>` with `Arc<T>` to reduce pointer chasing and memory overhead. - Leverage `Arc::from(Box<T>)` in async modify path for efficient ownership transfer. - Fix race conditions in `edit_draft` by ensuring atomicity under write lock. - Performance improved by ~16-24% across all operations (based on Criterion bench). Benchmarks: - latest_arc: 41.1ns (-24.2%) - edit_draft: 92.2ns (-17.6%) - apply: 89.8ns (-17.7%) - async_modify: 66.0ns (-16.6%) * perf(draft): implemented optimistic locking via Arc::ptr_eq for with_data_modify Benchmarks confirm only a negligible ~2% (1.3ns) overhead for async operations, ensuring total data integrity during concurrent updates.
16 lines
449 B
Rust
16 lines
449 B
Rust
use super::CmdResult;
|
|
use crate::{cmd::StringifyErr as _, config::IVerge, feat};
|
|
use clash_verge_draft::SharedDraft;
|
|
|
|
/// 获取Verge配置
|
|
#[tauri::command]
|
|
pub async fn get_verge_config() -> CmdResult<SharedDraft<IVerge>> {
|
|
feat::fetch_verge_config().await.stringify_err()
|
|
}
|
|
|
|
/// 修改Verge配置
|
|
#[tauri::command]
|
|
pub async fn patch_verge_config(payload: IVerge) -> CmdResult {
|
|
feat::patch_verge(&payload, false).await.stringify_err()
|
|
}
|