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.
26 lines
711 B
Rust
26 lines
711 B
Rust
// Copyright 2023 System76 <info@system76.com>
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
//! Select the preferred icon theme.
|
|
|
|
use std::borrow::Cow;
|
|
use std::sync::Mutex;
|
|
|
|
pub const COSMIC: &str = "Cosmic";
|
|
|
|
pub(crate) static DEFAULT: Mutex<Cow<'static, str>> = Mutex::new(Cow::Borrowed(COSMIC));
|
|
|
|
/// The fallback icon theme to search if no icon theme was specified.
|
|
#[must_use]
|
|
#[allow(clippy::missing_panics_doc)]
|
|
#[inline]
|
|
pub fn default() -> String {
|
|
DEFAULT.lock().unwrap().to_string()
|
|
}
|
|
|
|
/// Set the fallback icon theme to search when loading system icons.
|
|
#[allow(clippy::missing_panics_doc)]
|
|
#[cold]
|
|
pub fn set_default(name: impl Into<Cow<'static, str>>) {
|
|
*DEFAULT.lock().unwrap() = name.into();
|
|
}
|