diff --git a/src/base/action/component/after_prepare_component.rs b/src/base/action/component/after_prepare_component.rs index 813c3c09..233c1a7b 100644 --- a/src/base/action/component/after_prepare_component.rs +++ b/src/base/action/component/after_prepare_component.rs @@ -44,18 +44,19 @@ impl AfterPrepare { } #[inline(always)] + #[allow(clippy::inline_always)] pub(crate) fn dispatch(component: &mut C, cx: &mut Context) { dispatch_actions( - ActionKey::new(TypeId::of::(), None, Some(TypeId::of::()), None), + &ActionKey::new(TypeId::of::(), None, Some(TypeId::of::()), None), |action: &Self| (action.f)(component, cx), ); - if component.id().is_some() { + if let Some(id) = component.id() { dispatch_actions( - ActionKey::new( + &ActionKey::new( TypeId::of::(), None, Some(TypeId::of::()), - component.id(), + Some(id), ), |action: &Self| (action.f)(component, cx), ); diff --git a/src/base/action/component/before_prepare_component.rs b/src/base/action/component/before_prepare_component.rs index 206f1177..cedc45db 100644 --- a/src/base/action/component/before_prepare_component.rs +++ b/src/base/action/component/before_prepare_component.rs @@ -44,18 +44,19 @@ impl BeforePrepare { } #[inline(always)] + #[allow(clippy::inline_always)] pub(crate) fn dispatch(component: &mut C, cx: &mut Context) { dispatch_actions( - ActionKey::new(TypeId::of::(), None, Some(TypeId::of::()), None), + &ActionKey::new(TypeId::of::(), None, Some(TypeId::of::()), None), |action: &Self| (action.f)(component, cx), ); - if component.id().is_some() { + if let Some(id) = component.id() { dispatch_actions( - ActionKey::new( + &ActionKey::new( TypeId::of::(), None, Some(TypeId::of::()), - component.id(), + Some(id), ), |action: &Self| (action.f)(component, cx), ); diff --git a/src/base/action/component/is_renderable.rs b/src/base/action/component/is_renderable.rs index 7169d688..93159237 100644 --- a/src/base/action/component/is_renderable.rs +++ b/src/base/action/component/is_renderable.rs @@ -44,30 +44,33 @@ impl IsRenderable { } #[inline(always)] + #[allow(clippy::inline_always)] pub(crate) fn dispatch(component: &C, cx: &mut Context) -> bool { let mut renderable = true; dispatch_actions( - ActionKey::new(TypeId::of::(), None, Some(TypeId::of::()), None), + &ActionKey::new(TypeId::of::(), None, Some(TypeId::of::()), None), |action: &Self| { if renderable && !(action.f)(component, cx) { renderable = false; } }, ); - if renderable && component.id().is_some() { - dispatch_actions( - ActionKey::new( - TypeId::of::(), - None, - Some(TypeId::of::()), - component.id(), - ), - |action: &Self| { - if renderable && !(action.f)(component, cx) { - renderable = false; - } - }, - ); + if renderable { + if let Some(id) = component.id() { + dispatch_actions( + &ActionKey::new( + TypeId::of::(), + None, + Some(TypeId::of::()), + Some(id), + ), + |action: &Self| { + if renderable && !(action.f)(component, cx) { + renderable = false; + } + }, + ); + } } renderable } diff --git a/src/base/action/page/after_prepare_body.rs b/src/base/action/page/after_prepare_body.rs index b13bd8a9..9eb2f397 100644 --- a/src/base/action/page/after_prepare_body.rs +++ b/src/base/action/page/after_prepare_body.rs @@ -24,9 +24,10 @@ impl AfterPrepareBody { } #[inline(always)] + #[allow(clippy::inline_always)] pub(crate) fn dispatch(page: &mut Page) { dispatch_actions( - ActionKey::new(TypeId::of::(), None, None, None), + &ActionKey::new(TypeId::of::(), None, None, None), |action: &Self| (action.f)(page), ); } diff --git a/src/base/action/page/before_prepare_body.rs b/src/base/action/page/before_prepare_body.rs index 14499f1f..c1ea5beb 100644 --- a/src/base/action/page/before_prepare_body.rs +++ b/src/base/action/page/before_prepare_body.rs @@ -24,9 +24,10 @@ impl BeforePrepareBody { } #[inline(always)] + #[allow(clippy::inline_always)] pub(crate) fn dispatch(page: &mut Page) { dispatch_actions( - ActionKey::new(TypeId::of::(), None, None, None), + &ActionKey::new(TypeId::of::(), None, None, None), |action: &Self| (action.f)(page), ); } diff --git a/src/base/action/theme/after_prepare_component.rs b/src/base/action/theme/after_prepare_component.rs index 11df5ea9..7285aec1 100644 --- a/src/base/action/theme/after_prepare_component.rs +++ b/src/base/action/theme/after_prepare_component.rs @@ -28,9 +28,10 @@ impl AfterPrepare { } #[inline(always)] + #[allow(clippy::inline_always)] pub(crate) fn dispatch(component: &mut C, cx: &mut Context) { dispatch_actions( - ActionKey::new( + &ActionKey::new( TypeId::of::(), Some(cx.theme().type_id()), Some(TypeId::of::()), diff --git a/src/base/action/theme/before_prepare_component.rs b/src/base/action/theme/before_prepare_component.rs index c0cf0e13..7c80a655 100644 --- a/src/base/action/theme/before_prepare_component.rs +++ b/src/base/action/theme/before_prepare_component.rs @@ -28,9 +28,10 @@ impl BeforePrepare { } #[inline(always)] + #[allow(clippy::inline_always)] pub(crate) fn dispatch(component: &mut C, cx: &mut Context) { dispatch_actions( - ActionKey::new( + &ActionKey::new( TypeId::of::(), Some(cx.theme().type_id()), Some(TypeId::of::()), diff --git a/src/base/action/theme/render_component.rs b/src/base/action/theme/render_component.rs index 670151ee..e79c5c92 100644 --- a/src/base/action/theme/render_component.rs +++ b/src/base/action/theme/render_component.rs @@ -28,10 +28,11 @@ impl RenderComponent { } #[inline(always)] + #[allow(clippy::inline_always)] pub(crate) fn dispatch(component: &C, cx: &mut Context) -> Option { let mut render_component: Option = None; dispatch_actions( - ActionKey::new( + &ActionKey::new( TypeId::of::(), Some(cx.theme().type_id()), Some(TypeId::of::()), diff --git a/src/core/action/all.rs b/src/core/action/all.rs index 42a34e0e..76256939 100644 --- a/src/core/action/all.rs +++ b/src/core/action/all.rs @@ -19,12 +19,12 @@ pub fn add_action(action: ActionBox) { } } -pub fn dispatch_actions(key: ActionKey, f: F) +pub fn dispatch_actions(key: &ActionKey, f: F) where A: ActionTrait, F: FnMut(&A) -> B, { - if let Some(list) = ACTIONS.read().unwrap().get(&key) { - list.iter_map(f) + if let Some(list) = ACTIONS.read().unwrap().get(key) { + list.iter_map(f); } }