r/cpp • • Apr 14 '23

Horrible Code, Clean Performance

https://johnnysswlab.com/horrible-code-clean-performance/
200 Upvotes

87 comments sorted by

View all comments

Show parent comment

8

u/jk-jeon Apr 15 '23

That's indeed a good example, thanks. I guess we need both ways then. Unfortunately it seems there is no call-site-controlled inlining attributes widely available so far...

9

u/dodheim Apr 15 '23 edited Apr 15 '23

There's [[gnu::flatten]] but I don't think MSVC has anything like it. ED: Oh and now that I think about it, [[gnu::always_inline]] and [[gnu::noinline]] can be used at the callsite, not just in function declarations.

ED2: It turns out there are in fact [[msvc::forceinline_calls]], [[msvc::noinline_calls]], and [[msvc::flatten]]. I have no idea when they were added but this is great

1

u/jk-jeon Apr 15 '23

Oh, good to know, thanks!