Another reason why C-style for loops are bad: the test is reevaluated every iteration, which creates nasty optimization gotchas
-
-
*insert angry rant about how this is actually a very useful feature that is critical to my use case*
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
In JS, I often do `for (var i = 0, l = arr.length; i < l; i++) { ... }` for this very reason. I don't trust the compiler can optimize it.
-
I remember
@mraleph having a good post about how this "optimization" can do even an opposite. - 2 more replies
New conversation -
-
-
@jckarter even more fun when it's behind a dynamic dispatch boundary… for (int i = 0; i < CFArrayGetCount(arr); i++) { … }Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
the kind of things macro writers knows so well
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
This is why us perf-minded folks are writing for(int I = 0, len = arr->len; I < len; I++) out of habit.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
@jckarter yes! In the general case: use languages that capture the user’s intent. Build tools that let us create those languages.Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.