Item 11: Understand the Attraction of Small Functions(Effective C#)
转载 Remember that translating your C# code into machine-executable code is a two-step process. The C# compiler generates IL that gets delivered in assemblies. The JIT compiler generates machine code for each method (or group of methods, when inlining is involved), as needed. Small functions make it much easier for the JIT compiler to amortize that cost. Small functions are also more likely to be candidates for inlining. It’s not just smallness: Simpler control flow matters just as much. Fewer control branches inside functions make it easier for the JIT compiler to enregister variables. It’s not just good practice to write clearer code; it’s how you create more efficient code at runtime.
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:Item 12: Prefer Member Initializers to Assignment Statements(Effective C#)
下一篇:Item 10: Use Optional Parameters to Minimize Method Overloads(Effective C#)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章