diff --git a/leptos_dom/src/components/dyn_child.rs b/leptos_dom/src/components/dyn_child.rs index af8693bc9..ab790872d 100644 --- a/leptos_dom/src/components/dyn_child.rs +++ b/leptos_dom/src/components/dyn_child.rs @@ -139,13 +139,15 @@ where /// Creates a new dynamic child which will re-render whenever it's /// signal dependencies change. #[track_caller] + #[inline(always)] pub fn new(child_fn: CF) -> Self { Self::new_with_id(HydrationCtx::id(), child_fn) } #[doc(hidden)] #[track_caller] - pub fn new_with_id(id: HydrationKey, child_fn: CF) -> Self { + #[inline(always)] + pub const fn new_with_id(id: HydrationKey, child_fn: CF) -> Self { Self { id, child_fn } } } diff --git a/leptos_dom/src/components/each.rs b/leptos_dom/src/components/each.rs index 3ab3bb6f1..89613ab50 100644 --- a/leptos_dom/src/components/each.rs +++ b/leptos_dom/src/components/each.rs @@ -257,6 +257,7 @@ impl Mountable for EachItem { } } + #[inline(always)] fn get_opening_node(&self) -> web_sys::Node { #[cfg(debug_assertions)] return self.opening.node.clone(); @@ -328,7 +329,8 @@ where T: 'static, { /// Creates a new [`Each`] component. - pub fn new(items_fn: IF, key_fn: KF, each_fn: EF) -> Self { + #[inline(always)] + pub const fn new(items_fn: IF, key_fn: KF, each_fn: EF) -> Self { Self { items_fn, each_fn, diff --git a/leptos_dom/src/components/errors.rs b/leptos_dom/src/components/errors.rs index 4c8983e37..392e81dcd 100644 --- a/leptos_dom/src/components/errors.rs +++ b/leptos_dom/src/components/errors.rs @@ -5,16 +5,18 @@ use std::{collections::HashMap, error::Error, sync::Arc}; /// A struct to hold all the possible errors that could be provided by child Views #[derive(Debug, Clone, Default)] +#[repr(transparent)] pub struct Errors(HashMap>); /// A unique key for an error that occurs at a particular location in the user interface. #[derive(Debug, Default, Clone, PartialEq, Eq, Hash)] -pub struct ErrorKey(String); +#[repr(transparent)] impl From for ErrorKey where T: Into, { + #[inline(always)] fn from(key: T) -> ErrorKey { ErrorKey(key.into()) } @@ -24,12 +26,14 @@ impl IntoIterator for Errors { type Item = (ErrorKey, Arc); type IntoIter = IntoIter; + #[inline(always)] fn into_iter(self) -> Self::IntoIter { IntoIter(self.0.into_iter()) } } /// An owning iterator over all the errors contained in the [Errors] struct. +#[repr(transparent)] pub struct IntoIter( std::collections::hash_map::IntoIter< ErrorKey, @@ -40,6 +44,7 @@ pub struct IntoIter( impl Iterator for IntoIter { type Item = (ErrorKey, Arc); + #[inline(always)] fn next( &mut self, ) -> std::option::Option<::Item> { @@ -48,6 +53,7 @@ impl Iterator for IntoIter { } /// An iterator over all the errors contained in the [Errors] struct. +#[repr(transparent)] pub struct Iter<'a>( std::collections::hash_map::Iter< 'a, @@ -59,6 +65,7 @@ pub struct Iter<'a>( impl<'a> Iterator for Iter<'a> { type Item = (&'a ErrorKey, &'a Arc); + #[inline(always)] fn next( &mut self, ) -> std::option::Option<::Item> { @@ -127,6 +134,7 @@ where } impl Errors { /// Returns `true` if there are no errors. + #[inline(always)] pub fn is_empty(&self) -> bool { self.0.is_empty() } @@ -156,6 +164,7 @@ impl Errors { } /// An iterator over all the errors, in arbitrary order. + #[inline(always)] pub fn iter(&self) -> Iter<'_> { Iter(self.0.iter()) } diff --git a/leptos_dom/src/components/fragment.rs b/leptos_dom/src/components/fragment.rs index cdcbc5d92..f7b8be481 100644 --- a/leptos_dom/src/components/fragment.rs +++ b/leptos_dom/src/components/fragment.rs @@ -43,17 +43,20 @@ impl From for Fragment { impl Fragment { /// Creates a new [`Fragment`] from a [`Vec`]. + #[inline(always)] pub fn new(nodes: Vec) -> Self { Self::new_with_id(HydrationCtx::id(), nodes) } /// Creates a new [`Fragment`] from a function that returns [`Vec`]. + #[inline(always)] pub fn lazy(nodes: impl FnOnce() -> Vec) -> Self { Self::new_with_id(HydrationCtx::id(), nodes()) } /// Creates a new [`Fragment`] with the given hydration ID from a [`Vec`]. - pub fn new_with_id(id: HydrationKey, nodes: Vec) -> Self { + #[inline(always)] + pub const fn new_with_id(id: HydrationKey, nodes: Vec) -> Self { Self { id, nodes, @@ -63,11 +66,13 @@ impl Fragment { } /// Gives access to the [View] children contained within the fragment. + #[inline(always)] pub fn as_children(&self) -> &[View] { &self.nodes } /// Returns the fragment's hydration ID. + #[inline(always)] pub fn id(&self) -> &HydrationKey { &self.id } diff --git a/leptos_dom/src/components/unit.rs b/leptos_dom/src/components/unit.rs index 2b7188d48..866b86e47 100644 --- a/leptos_dom/src/components/unit.rs +++ b/leptos_dom/src/components/unit.rs @@ -40,14 +40,17 @@ impl Default for UnitRepr { #[cfg(all(target_arch = "wasm32", feature = "web"))] impl Mountable for UnitRepr { + #[inline(always)] fn get_mountable_node(&self) -> web_sys::Node { self.comment.node.clone().unchecked_into() } + #[inline(always)] fn get_opening_node(&self) -> web_sys::Node { self.comment.node.clone().unchecked_into() } + #[inline(always)] fn get_closing_node(&self) -> web_sys::Node { self.comment.node.clone().unchecked_into() } diff --git a/leptos_dom/src/macro_helpers/into_attribute.rs b/leptos_dom/src/macro_helpers/into_attribute.rs index 974f75878..94001fb00 100644 --- a/leptos_dom/src/macro_helpers/into_attribute.rs +++ b/leptos_dom/src/macro_helpers/into_attribute.rs @@ -135,6 +135,7 @@ macro_rules! impl_into_attr_boxed { } impl IntoAttribute for Option { + #[inline(always)] fn into_attribute(self, cx: Scope) -> Attribute { self.unwrap_or(Attribute::Option(cx, None)) }