Quantcast
Viewing all articles
Browse latest Browse all 59

Answer by rabbitfang

*This is from what I learned from quick research on the Internet* From a native-code perspective (code like C/C++, not C#), the equality operator and the greater than operator would consume the same number of operation codes (only one). How this relates to actual speed, I do not know. From a bit-comparison standpoint, the equality operator will be faster as only a bitwise AND operation would need to be performed on the value, where the comparison would be more complex. From a programming standpoint, if a variable will only contain a yes/no, 1/0, true/false value, it would be better to use a `boolean` variable, which (in theory), would be faster than integer comparison (equality or inequality); also, because the variable is prefixed with `is`, by convention it should be a `boolean`. If you know for certain that the value will never be either 1 or 0, then I would use `==`. If it is possible for it to be a value other than 1 or 0 (or just for safety), I would use `!= 0` or `== 0`. To answer the question, there is no noticeable difference within Mono (.NET implementation). If you have performance critical code that requires as much speed as you can muster, you should be using plugins. P.S. "taxing on the compiler" is asking about when you build your project, not when it is running.

Viewing all articles
Browse latest Browse all 59

Trending Articles