Benefits of declaring a function as “inline”?

前端 未结 10 1887
天涯浪人
天涯浪人 2020-12-09 14:01

Every time I read about the \"inline\" declaration in C it is mentioned that it is only a hint to the compiler (i.e. it does not have to obey it). Is there any benefit to ad

10条回答
  •  Happy的楠姐
    2020-12-09 14:34

    Generally modern compilers will "inline" things they deem important. I'd let it handle it for you.

    Edit:

    After reading what others have written, you know what? I think I'd let it handle most of the inlining THEN profile your code and THEN inline functions which are bottlenecks. My advise is slightly colored by a certain developer I work alongside who pre-optimizes all his code. Half the time I need to spend 5 min. just figuring out what is trying to be accomplished.

提交回复
热议问题