From 32a3ca5aeb025328e13068dd6190453480146eac Mon Sep 17 00:00:00 2001 From: Kaede Hoshikawa Date: Fri, 22 Apr 2022 23:58:36 +0900 Subject: [PATCH] Optimise Code size? --- packages/yew/src/html/component/scope.rs | 28 ++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/yew/src/html/component/scope.rs b/packages/yew/src/html/component/scope.rs index f6623944b79..c99cf8d2325 100644 --- a/packages/yew/src/html/component/scope.rs +++ b/packages/yew/src/html/component/scope.rs @@ -353,7 +353,8 @@ mod feat_csr_ssr { }) } - pub(super) fn schedule_update(&self) { + #[inline] + fn schedule_update(&self) { scheduler::push_component_update(Box::new(UpdateRunner { state: self.state.clone(), })); @@ -415,6 +416,22 @@ mod feat_csr { } } + fn schedule_props_update( + state: Shared>, + props: Rc, + node_ref: NodeRef, + next_sibling: NodeRef, + ) { + scheduler::push_component_props_update(Box::new(PropsUpdateRunner { + state, + node_ref, + next_sibling, + props, + })); + // Not guaranteed to already have the scheduler started + scheduler::start(); + } + impl Scope where COMP: BaseComponent, @@ -463,14 +480,7 @@ mod feat_csr { #[cfg(debug_assertions)] super::super::log_event(self.id, "reuse"); - scheduler::push_component_props_update(Box::new(PropsUpdateRunner { - state: self.state.clone(), - node_ref, - next_sibling, - props, - })); - // Not guaranteed to already have the scheduler started - scheduler::start(); + schedule_props_update(self.state.clone(), props, node_ref, next_sibling) } }