Skip to content

Commit

Permalink
refactor: Remove unnecessary clone when using use_sync_memo
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Mar 2, 2025
1 parent 08e319d commit dd0a408
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/use_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ where
K: 'static + Eq + Hash + Clone,
{
let client = use_query_client();
use_sync_memo(query_keys.clone(), || {
use_sync_memo(query_keys, move |query_keys| {
let mut query = query();
query.registry_entry.query_keys = query_keys.to_vec();

Expand Down Expand Up @@ -205,7 +205,7 @@ where
/// - T needs to be Clone (cannot be avoided)
fn use_sync_memo<T: 'static + Clone, D: PartialEq + 'static>(
deps: D,
init: impl FnOnce() -> T,
init: impl FnOnce(&D) -> T,
) -> T {
struct Memoized<T, D> {
value: T,
Expand All @@ -220,7 +220,7 @@ fn use_sync_memo<T: 'static + Clone, D: PartialEq + 'static>(
!= Some(&deps);

let new_value = if deps_have_changed {
Some(init())
Some(init(&deps))
} else {
None
};
Expand Down

0 comments on commit dd0a408

Please sign in to comment.