diff options
| author | sigoden <sigoden@gmail.com> | 2023-11-07 10:21:17 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-07 10:21:17 +0800 |
| commit | 87aec71e080dc9c15f3dd0059dbc91686f3de4e6 (patch) | |
| tree | 962ade482812d222d0681af6e4f5de946e3c86cf /src/client | |
| parent | 81624f7267ba20799a3bbf779abfe41df30d349c (diff) | |
| download | aichat-87aec71e080dc9c15f3dd0059dbc91686f3de4e6.tar.gz | |
refactor: use &GlobalConfig to avoid clone (#217)
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/common.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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<Box<dyn Client>> { + pub fn init(global_config: &$crate::config::GlobalConfig) -> Option<Box<dyn Client>> { 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<Box<dyn Client>> { + pub fn init_client(config: &$crate::config::GlobalConfig) -> anyhow::Result<Box<dyn Client>> { None - $(.or_else(|| $client::init(config.clone())))+ + $(.or_else(|| $client::init(config)))+ .ok_or_else(|| { let model = config.read().model.clone(); anyhow::anyhow!( |
