5 ms·
The author's observed speed discrepancy between iterators and while loops makes me think that they forgot to compile with optimizations, as the difference betwe
by kibwen 12y ago
The author's observed speed discrepancy between iterators and while loops makes me think that they forgot to compile with optimizations, as the difference between those programs is almost negligible on my end.
- Manishearth 12y agoIIRC there _are_ some possible optimizations that we don't yet do for iterators; but these are something that can easily be added in the future, and not something that really impact design per se.
- Veedrac 12y agoTo add to this, I found that when using i64 both generated exactly the same code.
- GolDDranks 12y agoI always thought that iterators would be _easier_ to optimize (assuming that the compiler can statically access the implementation) because they are more constrained in form at the use site. Loop unrolling etc.