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

View File

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