Repository navigation
Add #[inline] to Either::fold - #147
Conversation
|
I'm surprised this is needed -- this is a generic function so it should get local codegen, and it's small enough that I would even expect the MIR inliner to process it proactively. Do you have any analysis why that's not happening? If we need this one, we should probably inline all iterator methods, but I'd like to understand why. |
|
I don't have an analysis of why it wasn't happening, just that it wasn't happening. In the code I was building (part of rust-lang/rust#163744 ), rust-lang/rust#163775 is an example of a similar, sizable win provided by inlining methods that seem like they should be simple enough to not need the hint. I don't know if inlining every method is the right answer, but it does seem likely that inlining all the simple ones might be. |
Well, the methods are all equally simple here, merely dispatching to the inner variant. |
|
I think one reason the Want me to rework this to add the annotations to everything? ( |
|
Let's at least be consistent with |
This provided a non-trivial performance improvement when I was doing some compiler performance work, saving 1.5M instructions on some hot paths that were using Either for an iterator.
f05d61f to
ecabe24
Compare
|
@cuviper Done. |
|
Thanks! |
This provided a non-trivial performance improvement when I was doing
some compiler performance work, saving 1.5M instructions on some hot
paths that were using Either for an iterator.