remove unnecessary clones from code (#682)

This commit is contained in:
Adil Hafeez 2026-01-08 15:11:05 -08:00 committed by GitHub
parent 40b9780774
commit 11fb4cd633
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 35 additions and 40 deletions

View file

@ -14,7 +14,7 @@ impl LlmProviders {
}
pub fn default(&self) -> Option<Rc<LlmProvider>> {
self.default.as_ref().map(|rc| rc.clone())
self.default.clone()
}
pub fn get(&self, name: &str) -> Option<Rc<LlmProvider>> {
@ -58,19 +58,21 @@ impl TryFrom<Vec<LlmProvider>> for LlmProviders {
let name = llm_provider.name.clone();
if llm_providers
.providers
.insert(name.clone(), llm_provider.clone())
.insert(name.clone(), Rc::clone(&llm_provider))
.is_some()
{
return Err(LlmProvidersNewError::DuplicateName(name));
}
// also add model_id as key for provider lookup
if llm_providers
.providers
.insert(llm_provider.model.clone().unwrap(), llm_provider)
.is_some()
{
return Err(LlmProvidersNewError::DuplicateName(name));
if let Some(model) = llm_provider.model.clone() {
if llm_providers
.providers
.insert(model, llm_provider)
.is_some()
{
return Err(LlmProvidersNewError::DuplicateName(name));
}
}
}
Ok(llm_providers)