rust/src/libserialize
bors 866a713258 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.
2018-07-29 21:37:47 +00:00
..
Cargo.toml Bump version, upgrade bootstrap 2017-02-03 13:25:46 -08:00
collection_impls.rs Remove most of PartialEq impls from AST and HIR structures 2018-07-14 14:56:57 +03:00
hex.rs migrate codebase to ..= inclusive range patterns 2018-06-26 07:53:30 -07:00
json.rs Auto merge of #52738 - ljedrz:push_to_extend, r=eddyb 2018-07-29 21:37:47 +00:00
leb128.rs Make opaque::Encoder append-only and make it infallible 2018-06-27 11:43:15 +02:00
lib.rs Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
opaque.rs Make opaque::Encoder append-only and make it infallible 2018-06-27 11:43:15 +02:00
serialize.rs Fix Decodable impl for Arc 2018-03-02 10:45:32 +01:00