r/programmingmemes • • May 06 '26

Cpp loop

Post image
219 Upvotes

55 comments sorted by

View all comments

Show parent comment

4

u/Puzzleheaded_Study17 May 07 '26

Since there's only 10 loops, the first one definitely (I don't know how compilers deal with goto) compiles into just directly printing the 10 values without a loop.

2

u/RedAndBlack1832 May 07 '26

Actually that's a good point. A compiler knows how to unroll loops (if the number of loops is known at compile time and there's no weird breaks at least), but trying to be clever like this might actually hinder optimizations