You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@wcampbell0x2a it could call all those trait methods at compile time if possible and/or optimize them out:
![image](https://user-images.githubusercontent.com/108802164/235850935-15d0a95c-5733-48ac-8dc2-fb14f52ebbfc.png)
see [feature const-trait-impl](https://doc.rust-lang.org/beta/unstable-book/language-features/const-trait-impl.html)
I'm not sure how #[inline] interacts with this. I'm guessing if the call can't be optimized out at compile time, it inlines. It could also be the case that constness is only relevant to the crate where it is defined.
See the last line here (which I used on some From impls lately):
None: The compiler will decide itself if the function should be inlined. This will depend on factors such as the optimization level and the size of the function. Non-generic functions will never be inlined across crate boundaries unless link-time optimization is used; generic functions might be.
#[inline]: This suggests that the function should be inlined, including across crate boundaries.
Then again, I might have mixed this up (even non-const stuff can get computed at compile time), so if someone wants to go at this, it's probably best to first try to put #[inline] on those trait methods and compare asm outputs.
Edit: I quickly tried adding #[inline] to all the reads and writes in impls::primitives, it didn't inline (and I wouldn't use inline(always)).
Previous Issue
@wcampbell0x2a it could call all those trait methods at compile time if possible and/or optimize them out: ![image](https://user-images.githubusercontent.com/108802164/235850935-15d0a95c-5733-48ac-8dc2-fb14f52ebbfc.png) see [feature const-trait-impl](https://doc.rust-lang.org/beta/unstable-book/language-features/const-trait-impl.html)
I'm not sure how
#[inline]
interacts with this. I'm guessing if the call can't be optimized out at compile time, it inlines. It could also be the case that constness is only relevant to the crate where it is defined.See the last line here (which I used on some
From
impls lately):Then again, I might have mixed this up (even non-const stuff can get computed at compile time), so if someone wants to go at this, it's probably best to first try to put
#[inline]
on those trait methods and compare asm outputs.Edit: I quickly tried adding
#[inline]
to all theread
s andwrite
s inimpls::primitives
, it didn't inline (and I wouldn't use inline(always)).Originally posted by @hecatia-elegua in #308 (comment)
The text was updated successfully, but these errors were encountered: