0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-22 05:58:21 -05:00

Remove unnecessary clones

This commit is contained in:
Zsombor Gegesy 2023-09-12 07:37:33 +02:00
parent 519ebe0fd8
commit 320f5f4720
2 changed files with 6 additions and 6 deletions

8
src/cache/cacher.rs vendored
View File

@ -62,17 +62,17 @@ impl Cache {
/// * `url` - It takes the url as a String.
pub async fn cache_results(
&mut self,
search_results: SearchResults,
search_results: &SearchResults,
url: &str,
) -> Result<(), Report<PoolError>> {
match self {
Cache::Redis(redis_cache) => {
let json = serde_json::to_string(&search_results)
let json = serde_json::to_string(search_results)
.map_err(|_| PoolError::SerializationError)?;
redis_cache.cache_results(&json, url).await
}
Cache::InMemory(cache) => {
cache.insert(url.to_string(), search_results);
cache.insert(url.to_string(), search_results.clone());
Ok(())
}
}
@ -102,7 +102,7 @@ impl SharedCache {
/// `SearchResults` as the value.
pub async fn cache_results(
&self,
search_results: SearchResults,
search_results: &SearchResults,
url: &str,
) -> Result<(), Report<PoolError>> {
let mut mut_cache = self.cache.lock().await;

View File

@ -208,7 +208,7 @@ async fn results(
results.set_disallowed();
results.add_style(&config.style);
results.set_page_query(query);
cache.cache_results(results.clone(), &url).await?;
cache.cache_results(&results, &url).await?;
return Ok(results);
}
}
@ -256,7 +256,7 @@ async fn results(
results.set_filtered();
}
results.add_style(&config.style);
cache.cache_results(results.clone(), &url).await?;
cache.cache_results(&results, &url).await?;
Ok(results)
}
}