lysdexic@programming.dev to Programming@programming.devEnglish · 10 months agoPush Ifs Up And Fors Downmatklad.github.ioexternal-linkmessage-square22fedilinkarrow-up156arrow-down16cross-posted to: [email protected][email protected][email protected]
arrow-up150arrow-down1external-linkPush Ifs Up And Fors Downmatklad.github.iolysdexic@programming.dev to Programming@programming.devEnglish · 10 months agomessage-square22fedilinkcross-posted to: [email protected][email protected][email protected]
minus-squarepipe01@lemmy.pipe01.netlinkfedilinkarrow-up1·10 months agoYou still need to read the variable in each iteration, but the cost of that is probably negligible
minus-squareRyan@programming.devlinkfedilinkEnglisharrow-up5arrow-down1·edit-210 months agoModern 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.
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.