Remix.run Logo
▲ flohofwoe a day ago

> ...counting backwards in a for loop is faster...

Maybe in 1990 ;)

(it's one of many cargo cult wisdom snippets that have become mostly obsolete once C compilers got proper optimizer passes and CPUs got all sorts of pipeling tricks)

▲bugake 9 hours ago | parent [-]

A cargo cult wisdom snippet is the belief that compilers automagically apply every possible optimization. But they don't, because compilers don't know everything you know. Compilers have to assume that your code can be subject to side effects you never thought of, that would change the result of the code, so a lot of possible optimizations are avoided.

▲flohofwoe 3 hours ago | parent [-]

Well you check the compiler output and profile of course. But "generalized" performance advice like "use reverse loops" hasn't been relevant for a long time, it's a similar myth like "pre-increment is faster than post-increment".