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
|
|
@ -16,6 +16,7 @@ pub struct ThemeMode {
|
|||
}
|
||||
|
||||
impl Default for ThemeMode {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
is_dark: true,
|
||||
|
|
@ -25,15 +26,19 @@ impl Default for ThemeMode {
|
|||
}
|
||||
|
||||
impl ThemeMode {
|
||||
#[inline]
|
||||
/// Check if the theme is currently using dark mode
|
||||
pub fn is_dark(config: &Config) -> Result<bool, cosmic_config::Error> {
|
||||
config.get::<bool>("is_dark")
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// The current version of the theme mode config.
|
||||
pub const fn version() -> u64 {
|
||||
Self::VERSION
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Get the config for the theme mode
|
||||
pub fn config() -> Result<Config, cosmic_config::Error> {
|
||||
Config::new(THEME_MODE_ID, Self::VERSION)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue