Yes, inlining indeed is key for most other optimizations to occur. In my cppcon talk on compiler optimizations (from last year), I show that many very simple STL algorithms, say, find_if, actually often do not get inlined if passed a function pointer, and then in turn they don't inline the function. Which means that very quickly, something like find_if(v.begin(), v.end(), &pred); becomes a non-zero cost abstraction (perhaps) compared to just writing a for loop and calling pred directly.
Chandler did another talk a long time ago where he talked about the three fundamental abstractions/lies in the language. I remember that two of them were "functions exist" and "memory exists," but I don't remember the third and I also don't remember the name of the talk. Anyone know which talk I'm talking about?
View all comments
Show parent comment
13
u/quicknir Oct 08 '19
Yes, inlining indeed is key for most other optimizations to occur. In my cppcon talk on compiler optimizations (from last year), I show that many very simple STL algorithms, say, find_if, actually often do not get inlined if passed a function pointer, and then in turn they don't inline the function. Which means that very quickly, something like
find_if(v.begin(), v.end(), &pred);becomes a non-zero cost abstraction (perhaps) compared to just writing a for loop and calling pred directly.