3 ms·
Not only does it generate more code, the initially generated code before optimizations is also often worse. For example, heavy use of iterators means a ton of
by treyd 1y ago
Not only does it generate more code, the initially generated code before optimizations is also often worse. For example, heavy use of iterators means a ton of generics being instantiated and a ton of call code for setting up and tearing down call frames. This gets heavily inlined and flattened out, so in the end it's extremely well-optimized, but it's a lot of work for the compiler. Writing it all out classically with for loops and ifs is possible, but it's harder to read.
- estebank 1y agoFor loops are sugar around an Iterator instantiation: for i in 0..10 {} translates to roughly let mut iter = Range { start: 0, end: 10 }.into_iter(); while let Some(i) = iter.next() {}