Given the following code:
const int constA = 10; const int constB = 10; function GetX(int input) { int x = constA * constB * input; ... return x; }
Will the .NET compiler replace the expression and put 1000 so that the calculation does not repeat over and over?
In which syntax will the code run faster:
I think option 3 will be faster than 2, but sometimes not the most readable one. Does the compiler recognize such patterns and optimize it accordingly?
performance compiler-optimization c # constants
amaters
source share