about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-07-29 21:37:47 +0000
committerbors <bors@rust-lang.org>2018-07-29 21:37:47 +0000
commit866a713258915e6cbb212d135f751a6a8c9e1c0a (patch)
treea167fe06a630b04423cfd159186a0eacc27afc52 /src/rustllvm/RustWrapper.cpp
parent70cac59031d5c33962a1f53cdca9359c0dcd1f9f (diff)
parent59c8a279daf6912b99ba089ff6dafbfc3469831e (diff)
downloadrust-866a713258915e6cbb212d135f751a6a8c9e1c0a.tar.gz
rust-866a713258915e6cbb212d135f751a6a8c9e1c0a.zip
Auto merge of #52738 - ljedrz:push_to_extend, r=eddyb
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.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions