Replace push loops with extend() where possible Or set the vector capacity where I couldn't do it. According to my [simple benchmark](https://gist.github.com/ljedrz/568e97621b749849684c1da71c27dceb) `extend`ing a vector can be over **10 times** faster than `push`ing to it in a loop: 10 elements (6.1 times faster): ``` test bench_extension ... bench: 75 ns/iter (+/- 23) test bench_push_loop ... bench: 458 ns/iter (+/- 142) ``` 100 elements (11.12 times faster): ``` test bench_extension ... bench: 87 ns/iter (+/- 26) test bench_push_loop ... bench: 968 ns/iter (+/- 3,528) ``` 1000 elements (11.04 times faster): ``` test bench_extension ... bench: 311 ns/iter (+/- 9) test bench_push_loop ... bench: 3,436 ns/iter (+/- 233) ``` Seems like a good idea to use `extend` as much as possible. |
||
|---|---|---|
| .. | ||
| deriving | ||
| asm.rs | ||
| assert.rs | ||
| Cargo.toml | ||
| cfg.rs | ||
| compile_error.rs | ||
| concat.rs | ||
| concat_idents.rs | ||
| diagnostics.rs | ||
| env.rs | ||
| format.rs | ||
| format_foreign.rs | ||
| global_asm.rs | ||
| lib.rs | ||
| log_syntax.rs | ||
| proc_macro_impl.rs | ||
| proc_macro_registrar.rs | ||
| trace_macros.rs | ||