From 87aec71e080dc9c15f3dd0059dbc91686f3de4e6 Mon Sep 17 00:00:00 2001 From: sigoden Date: Tue, 7 Nov 2023 10:21:17 +0800 Subject: refactor: use &GlobalConfig to avoid clone (#217) --- src/client/common.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/client') diff --git a/src/client/common.rs b/src/client/common.rs index 7959b46..336450f 100644 --- a/src/client/common.rs +++ b/src/client/common.rs @@ -52,7 +52,7 @@ macro_rules! register_client { impl $client { pub const NAME: &str = $name; - pub fn init(global_config: $crate::config::GlobalConfig) -> Option> { + pub fn init(global_config: &$crate::config::GlobalConfig) -> Option> { let model = global_config.read().model.clone(); let config = { if let ClientConfig::$config(c) = &global_config.read().clients[model.client_index] { @@ -62,7 +62,7 @@ macro_rules! register_client { } }; Some(Box::new(Self { - global_config, + global_config: global_config.clone(), config, model, })) @@ -75,9 +75,9 @@ macro_rules! register_client { )+ - pub fn init_client(config: $crate::config::GlobalConfig) -> anyhow::Result> { + pub fn init_client(config: &$crate::config::GlobalConfig) -> anyhow::Result> { None - $(.or_else(|| $client::init(config.clone())))+ + $(.or_else(|| $client::init(config)))+ .ok_or_else(|| { let model = config.read().model.clone(); anyhow::anyhow!( -- cgit v1.2.3