请问C#的内联属性? [英] Does C# inline properties?

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

问题描述

请问C#在线访问属性?我知道对JIT内联的32字节(指令?)限制,但将它内联属性或只的的方法调用?

Does C# inline access to properties? I'm aware of the 32 byte (instruction?) limit on the JIT for inlining, but will it inline properties or just pure method calls?

推荐答案

这是给了JIT(C#编译器不会做任何内联,据我所知),但我相信JIT将内联琐碎的性能在大多数情况下

It's up to the JIT (the C# compiler doesn't do any inlining as far as I'm aware), but I believe the JIT will inline trivial properties in most cases.

请注意,它的不会的类型的内联成员 MarshalByRefObject的导出其中包括 System.Windows.Forms的。控制(通过 System.ComponentModel.Component )。

Note that it won't inline members of types deriving from MarshalByRefObject which includes System.Windows.Forms.Control (via System.ComponentModel.Component).

我也看到了字段结束时,通过属性访问是低效率 - 这可能是因为周围有一些细微之处(由于使用登记等)

I've also seen double fields end up being less efficient when accessed via properties - it could be that there are some subtleties around that (due to register use etc).

还要注意的是64位和32位JIT们是不同的,包括它们的治疗什么得到内联。

Also note that the 64-bit and 32-bit JITs are different, including their treatment of what gets inlined.

编辑:我刚刚发现了一个 2004年的博客条目大卫Notario有一些更多的信息。然而,那是以前2.0运 - 我也不会感到惊讶地看到,至少中的部分的,现在发生了变化。可能会感兴趣呢。

I've just found a 2004 blog entry by David Notario with some more information. However, that was before 2.0 shipped - I wouldn't be surprised to see that at least some of it had changed now. Might be of interest anyway.

编辑: 提到了一个<一个又一个的问题href="http://blogs.msdn.com/vancem/archive/2008/08/19/to-inline-or-not-to-inline-that-is-the-question.aspx">2008万斯莫里森博客条目给出了更多的信息。有趣的东西。

Another question referred to a 2008 Vance Morrison blog entry which gives more information. Interesting stuff.

这篇关于请问C#的内联属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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