summaryrefslogtreecommitdiff
path: root/src/tools/miri/bench-cargo-miri/zip-equal/src/main.rs
blob: ba4e9b41d1d1d093947503e6a213975039aa4c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//! This is a pathological pattern in which opportunities to merge
//! adjacent identical items in the RangeMap are not properly detected
//! because `RangeMap::iter_mut` is never called on overlapping ranges
//! and thus never merges previously split ranges. This does not produce any
//! additional cost for access operations, but it makes the job of the Tree Borrows
//! GC procedure much more costly.
//! See https://github.com/rust-lang/miri/issues/2863

const LENGTH: usize = (1 << 14) - 1;
const LONG: &[u8] = &[b'x'; LENGTH];

fn main() {
    assert!(eq(LONG, LONG))
}

fn eq(s1: &[u8], s2: &[u8]) -> bool {
    if s1.len() != s2.len() {
        return false;
    }

    s1.iter().zip(s2).all(|(c1, c2)| *c1 == *c2)
}