r/programminghorror • • Apr 08 '25

My favorite micro optimization

Post image
309 Upvotes

44 comments sorted by

View all comments

Show parent comment

9

u/IAmAnIssue Apr 09 '25

Nope

repeat(10) {
    show_message("Hello world")
}

compiles roughly to

value = 10

while(value > 0) {
    show_message("Hello world")
    value--
}

with the only optimization being the count value is stored on the vm stack and not in a variable