Let's start a war in here

@LukeAlmighty Would I be right in saying for loops can be optimised since the number of iterations can be known beforehand whereas while loops cannot?

@thatbrickster
I'm not sure about that. I believe, that you can change the iterated variable from inside the for loop.

Follow

@LukeAlmighty @thatbrickster Compilers can unroll for loops with compile time values

One thing thats actually cooler though is that for loops can be parallalised with almost 0 effort while while loops can't, and these work on non-constants

omp parallel for

Before any for loop and it gets spread over as many threads as your cpu has

· · Web · 0 · 0 · 2
Sign in to participate in the conversation
Game Liberty Mastodon

Mainly gaming/nerd instance for people who value free speech. Everyone is welcome.