From 510386811929e2c1df6afea1da904d1e790c77f7 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Wed, 28 Jan 2026 10:28:26 +0800 Subject: [PATCH] perf: separate Clone implementation for Draft struct and remove trait bound from struct definition Improve around 2% - 16% CPU performance --- crates/clash-verge-draft/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/clash-verge-draft/src/lib.rs b/crates/clash-verge-draft/src/lib.rs index c1cba8f59..a26f1513b 100644 --- a/crates/clash-verge-draft/src/lib.rs +++ b/crates/clash-verge-draft/src/lib.rs @@ -6,8 +6,8 @@ type DraftInner = (SharedDraft, Option>); /// Draft 管理:committed 与 optional draft 都以 Arc> 存储, // (committed_snapshot, optional_draft_snapshot) -#[derive(Debug, Clone)] -pub struct Draft { +#[derive(Debug)] +pub struct Draft { inner: Arc>>, } @@ -90,3 +90,11 @@ impl Draft { Ok(res) } } + +impl Clone for Draft { + fn clone(&self) -> Self { + Self { + inner: Arc::clone(&self.inner), + } + } +}