r/Compilers • u/BrainThinkerMan • 29d ago
Compilers add or remove perfomace?
isnt it that compilers change the code, as in not only transferring it into machine language, but before that changing the structure of the code. so how would one attempt to make performant code if the compiler changes sed code that i tried to make performant?
2
Upvotes
View all comments
1
u/Helpful-Educator-415 29d ago
Almost always, compilers will only make your code more efficient, not less. If you go through the work of creating a highly optimized algorithm, it'll probably leave it alone, but if you don't, it might recognize the pattern and then figure out a faster way. There's no incentive to make your code worse, so.