]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #73529 - pickfire:liballoc-specfromelem-i8, r=cuviper
authorManish Goregaokar <manishsmail@gmail.com>
Fri, 26 Jun 2020 20:57:31 +0000 (13:57 -0700)
committerGitHub <noreply@github.com>
Fri, 26 Jun 2020 20:57:31 +0000 (13:57 -0700)
Add liballoc impl SpecFromElem for i8

Speedup vec![1_i8; N] for non-zero element.

Before
test do_bench_from_elem_i8        ... bench:         130 ns/iter (+/- 7) = 61 MB/s
test do_bench_from_elem_u8        ... bench:         121 ns/iter (+/- 4) = 66 MB/s
After
test do_bench_from_elem_i8        ... bench:         123 ns/iter (+/- 7) = 65 MB/s
test do_bench_from_elem_u8        ... bench:         121 ns/iter (+/- 5) = 66 MB/s

No speed difference if element is already zero.

```rust
#[bench]
fn do_bench_from_elem_i8(b: &mut Bencher) {
    b.bytes = 8 as u64;
    b.iter(|| {
        let dst = ve::vec![10_i8; 100];
        assert_eq!(dst.len(), 100);
        assert!(dst.iter().all(|x| *x == 10));
    })
}
```

As suggested by @cuviper
https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/SpecForElem.20for.20other.20integers

r? @cuviper
CC @joshtriplett

Edit: Wow, I just realized both reviewers are Josh.

1  2 
src/liballoc/vec.rs

Simple merge