perf: inline public getters/setters, and use non-generic inner functions
To reduce compile-times and avoid some overhead to binary size, this will modify some of our generic functions to use non-generic inner functions where possible. The inner functions are marked carefully with `#[inline(never)]` to prevent being inlined by LLVM at their callsites While looking for generic functions to optimize, I have also taken the opportunity to annotate public non-generic getters and setters with `#[inline]` to ensure that LLVM will inline them across crate boundaries. By default, only generic functions are automatically inlined, and only when enabling fat LTO are constant functions reliably inlined across crate boundaries.
This commit is contained in:
parent
c538d672df
commit
8cf372c9b9
55 changed files with 702 additions and 255 deletions
|
|
@ -113,6 +113,7 @@ impl Named {
|
|||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn handle(self) -> Handle {
|
||||
Handle {
|
||||
symbolic: self.symbolic,
|
||||
|
|
@ -120,6 +121,7 @@ impl Named {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn icon(self) -> Icon {
|
||||
let size = self.size;
|
||||
|
||||
|
|
@ -133,18 +135,21 @@ impl Named {
|
|||
}
|
||||
|
||||
impl From<Named> for Handle {
|
||||
#[inline]
|
||||
fn from(builder: Named) -> Self {
|
||||
builder.handle()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Named> for Icon {
|
||||
#[inline]
|
||||
fn from(builder: Named) -> Self {
|
||||
builder.icon()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Message: 'static> From<Named> for crate::Element<'_, Message> {
|
||||
#[inline]
|
||||
fn from(builder: Named) -> Self {
|
||||
builder.icon().into()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue