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:
parent
519ebe0fd8
commit
320f5f4720
8
src/cache/cacher.rs
vendored
8
src/cache/cacher.rs
vendored
@ -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;
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user