Do compilers combine math operations?
Go to solution
Solved by laxer,
Since no one has really successfully answered this question I will do it.
Yes the compiler will optimize the code, It is known as Constant Folding.
How you program it is personal preference. The performance is negligible when it is processed through the parser. (It will create one fewer node)
If you follow the holy bible of programming(Code Complete by McConnell)
It is better to write it out as the code is generally easier to follow.
In all honesty, absolutely no one cares about seconds saved during compiling. It is more important to make the code readable than it is to compile quickly.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now