RReeaallyy长功能 - 内联? [英] RReeaallyy long function -- inlining?

查看:60
本文介绍了RReeaallyy长功能 - 内联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



常见的劝说是:


大功能 - 保留大纲。


小功能 - 让它成为内联。

在我正在编写的代码中,我有一个相当长的功能,所以它不会让我想到b $ b使它内联。但是,这个函数只需要调用一次,而且它的调用是在

程序执行的最开始。


无论函数的大小如何,只要它被调用一次就没有意义使它成为内联的b / b
,因此它的代码是扩展的 -

place"而是存在某种内存重定向?


我应该坚持使用Big = outline,Small = inline的公式。并简单地

依靠编译器就地扩展代码如果函数只调用了一次




- Tomás

解决方案


$ b $bTomás写道:

我应该坚持公式Big = outline,Small = inline如果只调用一次函数,只需依靠编译器就地扩展代码?




也可以。无论如何,编译器都会做它的工作。它没有
必须服从内联关键字。你唯一能做的就是用一堆代码来填充标题......这将是b / b
肯定会增加你的编译时间和源代码依赖性。 br />


Tomás< NU ** @ NULL.NULL>写道:

常见的说服是:

大功能 - 保留大纲。

小功能 - 使其内联。

在我正在写的代码中,我有一个相当长的功能,所以
我不会想到让它内联。但是,该函数只被调用一次,并且它的调用是在程序执行的最开始。

无论函数的大小如何,如果它只被调用一次,那么它是否有意义是内联的,所以它的代码是扩展在 - / /地方。而是存在某种内存重定向?

我应该坚持使用Big = outline,Small = inline的公式。如果
函数只被调用一次,那么只需依靠编译器就地扩展代码?




如果只调用它曾经,为什么要关心它是否内联?

你将永远无法看到性能上的差异。


hth

-

jb


(回复地址rot13,先解读)


< blockquote class =post_quotes>如果只调用一次,为什么要关心它是否内联?
你将永远无法看到性能上的差异。



如果它被称为轮廓,则程序计数器将被移动。


如果它被称为内联,则控件将只需流入该功能。


-Tomás



The common persuasion is:

Big function -- leave it outline.

Small function -- make it inline.
In code I''m writing at the moment, I have a fairly long function, so it
wouldn''t cross my mind to make it inline. However, the function is
invoked only once, and its invokation is at the very beginning of the
program''s execution.

Regardless of a function''s size, would it not make sense to make it
inline if it''s only called once, so that it''s code is "expanded in-
place" rather that there being some sort of memory redirection?

Should I stick to the formula of "Big=outline, Small=inline" and simply
rely on the compiler to expand the code in-place if the function is only
invoked once?

-Tomás

解决方案


Tomás wrote:

Should I stick to the formula of "Big=outline, Small=inline" and simply
rely on the compiler to expand the code in-place if the function is only
invoked once?



May as well. The compiler will do what it does regardless. It doesn''t
have to obey the inline keyword. The only thing you will surely
accomplish is to fill a header up with a bunch of code...which will
increase your comile times and source code dependencies surely.


Tomás <NU**@NULL.NULL> wrote:

The common persuasion is:

Big function -- leave it outline.

Small function -- make it inline.
In code I''m writing at the moment, I have a fairly long function, so
it wouldn''t cross my mind to make it inline. However, the function is
invoked only once, and its invokation is at the very beginning of the
program''s execution.

Regardless of a function''s size, would it not make sense to make it
inline if it''s only called once, so that it''s code is "expanded in-
place" rather that there being some sort of memory redirection?

Should I stick to the formula of "Big=outline, Small=inline" and
simply rely on the compiler to expand the code in-place if the
function is only invoked once?



If it is only invoked once, why care whether it is inlined or not?
You will never be able to see a difference in performance.

hth
--
jb

(reply address in rot13, unscramble first)


If it is only invoked once, why care whether it is inlined or not?
You will never be able to see a difference in performance.



If it''s called "outline", then the program counter will be moved.

If it''s called "inline", the control will simply flow into the function.

-Tomás


这篇关于RReeaallyy长功能 - 内联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆