
rust@octodon.social ("Rust tips") wrote:
#Rustlang has a
#[cold]
optimization hint for rarely-called functions, and#[inline(never)]
that disables inlining.Use these two on expensive error handling functions to speed up compilation, reduce code size, and improve effectiveness of instruction cache.
#[cold]#[inline(never)]fn handle_error(err: &dyn Error) -> ! { …}impl MyError { #[cold] #[inline(never)] pub fn new() -> Self { … }}