Hi, 2013/5/30 James Miller <[email protected]>
> > Inlining is a pretty standard optimization, and is potentially done for > every function that isn't > marked with `#[inline(never)]`, but the compiler is smart enough to know > when it's not worth it. > `#[inline(always)]` is a very strong statement, and should be reserved for > cases where you are > certain that the function absolutely needs to be inlined, no exceptions. > Remember that "always" > means it, so every single function that uses it will get a copy. > > Inlining is not a magic bullet for performance and the compiler passes are > far smarter at knowing > what is more efficient than you are. > Why even have the option? The programmer almost never has better information than the compiler to decide whether a function could be beneficially inlined at each particular call site. And as we see with the Rust code base itself, this has a great potential of being unwittingly abused. Look, a "make my function run fast" directive! Plain #[inline] has a declarative value, though. I haven't looked into what the compiler does, but I guess #[inline] can instruct it to emit metadata for inlining a public function at the call site, rather than just shipping a symbol in the crate. Best regards, Mikhail
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
