From 21daff2879dd50dbe623b515fb486acced4e91cc Mon Sep 17 00:00:00 2001 From: Pauan Date: Mon, 17 May 2021 09:42:35 +0200 Subject: [PATCH] Changing apply_methods/html/svg to run each method call on a separate statement This means that any locks will be freed at the end of the method call --- src/animation.rs | 8 ++++---- src/macros.rs | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/animation.rs b/src/animation.rs index b470fd2..8c339f8 100644 --- a/src/animation.rs +++ b/src/animation.rs @@ -621,7 +621,7 @@ struct MutableAnimationState { playing: bool, duration: f64, end: Percentage, - animating: Option, + _animating: Option, } struct MutableAnimationInner { @@ -661,7 +661,7 @@ impl MutableAnimation { playing: true, duration: duration, end: initial, - animating: None, + _animating: None, }), value: Mutable::new(initial), }), @@ -682,7 +682,7 @@ impl MutableAnimation { #[inline] fn stop_animating(lock: &mut MutableAnimationState) { - lock.animating = None; + lock._animating = None; } fn start_animating(&self, lock: &mut MutableAnimationState) { @@ -697,7 +697,7 @@ impl MutableAnimation { let state = self.raw_clone(); - lock.animating = Some(OnTimestampDiff::new(move |diff| { + lock._animating = Some(OnTimestampDiff::new(move |diff| { let diff = diff / duration; // TODO test the performance of set_neq diff --git a/src/macros.rs b/src/macros.rs index 6cee21f..35f881a 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -3,15 +3,15 @@ macro_rules! apply_methods { ($this:expr, {}) => { $this }; - ($this:expr, { .$name:ident!($($args:tt)*) $($rest:tt)* }) => { - $crate::apply_methods!({ - let this = $this; - $name!(this, $($args)*) - }, { $($rest)* }) - }; - ($this:expr, { .$name:ident($($args:expr),*) $($rest:tt)* }) => { - $crate::apply_methods!($this.$name($($args),*), { $($rest)* }) - }; + ($this:expr, { .$name:ident!($($args:tt)*) $($rest:tt)* }) => {{ + let this = $this; + let this = $name!(this, $($args)*); + $crate::apply_methods!(this, { $($rest)* }) + }}; + ($this:expr, { .$name:ident($($args:expr),*) $($rest:tt)* }) => {{ + let this = $this.$name($($args),*); + $crate::apply_methods!(this, { $($rest)* }) + }}; }