Why is inlining considered faster than a function call?

前端 未结 16 1582
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 04:04

Now, I know it\'s because there\'s not the overhead of calling a function, but is the overhead of calling a function really that heavy (and worth the bloat of having it inli

16条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 04:23

    let

    int sum(const int &a,const int &b)
    {
         return a + b;
    }
    int a = sum(b,c);
    

    is equal to

    int a = b + c
    

    No jump - no overhead

提交回复
热议问题