毫无意义的分号会影响性能吗? [英] Will a pointless semicolon have any performance impact?

查看:51
本文介绍了毫无意义的分号会影响性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,我注意到我在语句后添加了一个额外的 ;.

Sometimes, I notice I add an additional ; after a statement.

示例:

Console.WriteLine("meow");;

这会影响我的应用程序的性能吗?具体来说,我想知道 C#.

Will that effect the performance in my app? Specifically, I am wondering about C#.

推荐答案

无;它不会影响编译器生成的 IL 代码.

None whatsoever; it will not impact the IL code that the compiler generates.

然而,它可能会对任何必须维护您的代码的同事产生性能影响...

It may however have a performance impact on any coworkers who have to maintain your code...

您可能有兴趣阅读关于 empty语句,例如

You might be interested in reading about empty statements, such as

bool ProcessMessage() {...}
void ProcessMessages() {
   while (ProcessMessage())
      ;
}

这篇关于毫无意义的分号会影响性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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