What is inlining?

前端 未结 10 1527
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 06:45

I am referring to this discussion. I have never written any code in C or in C++ . I do not have any CS background. However I have been working as Java developer for 5 years

10条回答
  •  离开以前
    2020-12-01 07:04

    As already mentioned in other answers, inlining comes with a cost. Usually this is considered small, however when actually measuring you might be surprised and learn that it might be greater than what you gain (so what other people say is true: do not optimize unless you have measured).

    It is worth noting that in the Linux kernel they started un-inlining originally inlined functions some time ago because the cost was too high (larger functions consumed more of the cpu memory cache, and the resulting cache misses were more expensive than just calling the function that were intended to be inlined). See "Chapter 15: The inline disease" in doc/Documentation/process/coding-style.rst for more details.

提交回复
热议问题