49
Push Ifs Up And Fors Down
(matklad.github.io)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
I'm curious, is there a difference in doing it like this?:
Doesn't assigning the condition to a variable make it so that it's only really evaluated once?
You still need to read the variable in each iteration, but the cost of that is probably negligible
Modern optimizing compilers are magical. I would need to check assembly but I would actually expect the if to be hoisted out of the loop entirely to relieve pressure on the branch predictor.