它是在C#中有用的应用德摩根定理手动优化条件语句布尔表达式(例如,如果条件) [英] Is it useful in C# to apply DeMorgan's theorem to manually optimize boolean expressions in conditional statements (e.g. if conditions)

查看:171
本文介绍了它是在C#中有用的应用德摩根定理手动优化条件语句布尔表达式(例如,如果条件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早在一天当我做了我的大部分C和C ++的工作,作为一个理所当然的事,我会手动应用的德摩根定理以优化任何不平凡的布尔表达式。

Back in the day when I did most of my work in C and C++, as a matter of course, I would manually apply deMorgan's theorem to optimize any non-trivial boolean expressions.

时是非常有用的在C#中做到这一点还是优化渲染这是不必要的?

Is it useful to do this in C# or does the optimizer render this unnecessary?

推荐答案

在处理器这个快速发展,这对清理布尔表达式,使在任何速度实际相差几乎是不可能的。和C#编译器很聪明,它会优化它。优化可读性和清晰度!

On processors this fast, it's virtually impossible for rearranging boolean expressions to make any actual difference in speed. And the C# compiler is very smart, it will optimize it as well. Optimize for readability and clarity!

这篇关于它是在C#中有用的应用德摩根定理手动优化条件语句布尔表达式(例如,如果条件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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