Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove newly-detected unused tuple fields #2169

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions leptos_reactive/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,12 +951,11 @@ impl RuntimeId {
false
};

let prev_observer =
SetObserverOnDrop(self, runtime.observer.take());
let prev_observer = SetObserverOnDrop(runtime.observer.take());

untracked_result = f();

runtime.observer.set(prev_observer.1);
runtime.observer.set(prev_observer.0);
std::mem::forget(prev_observer); // avoid Drop

#[cfg(debug_assertions)]
Expand Down Expand Up @@ -1371,12 +1370,12 @@ impl std::hash::Hash for Runtime {
}
}

struct SetObserverOnDrop(RuntimeId, Option<NodeId>);
struct SetObserverOnDrop(Option<NodeId>);

impl Drop for SetObserverOnDrop {
fn drop(&mut self) {
_ = with_runtime(|rt| {
rt.observer.set(self.1);
rt.observer.set(self.0);
});
}
}
Expand All @@ -1393,14 +1392,13 @@ impl Drop for SetObserverOnDrop {
)]
#[inline(always)]
pub fn batch<T>(f: impl FnOnce() -> T) -> T {
let runtime_id = Runtime::current();
with_runtime(move |runtime| {
let batching = SetBatchingOnDrop(runtime_id, runtime.batching.get());
let batching = SetBatchingOnDrop(runtime.batching.get());
runtime.batching.set(true);

let val = f();

runtime.batching.set(batching.1);
runtime.batching.set(batching.0);
std::mem::forget(batching);

runtime.run_effects();
Expand All @@ -1409,12 +1407,12 @@ pub fn batch<T>(f: impl FnOnce() -> T) -> T {
.expect("tried to run a batched update in a runtime that has been disposed")
}

struct SetBatchingOnDrop(RuntimeId, bool);
struct SetBatchingOnDrop(bool);

impl Drop for SetBatchingOnDrop {
fn drop(&mut self) {
_ = with_runtime(|rt| {
rt.batching.set(self.1);
rt.batching.set(self.0);
});
}
}
Expand Down
Loading