Skip to content

Instantly share code, notes, and snippets.

@dfyz
Created February 24, 2020 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfyz/36ecbcdcbde052bd11b457ad6df9548e to your computer and use it in GitHub Desktop.
Save dfyz/36ecbcdcbde052bd11b457ad6df9548e to your computer and use it in GitHub Desktop.
fn do_test(x: usize) {
let arr = vec![vec![0u8; 3]];
let mut z = vec![0];
for arr_ref in arr {
for y in 0..x {
for _ in 0..1 {
z.reserve_exact(x);
let iterator = std::iter::repeat(0).take(x);
let mut cnt = 0;
iterator.for_each(|_| {
z[0] = 0;
cnt += 1;
});
let a = y * x;
let b = (y + 1) * x - 1;
let slice = &arr_ref[a..b];
eprintln!("{} {} {} {}", a, b, arr_ref.len(), slice.len());
eprintln!("{:?}", slice[1 << 24]);
}
}
}
}
fn main() {
do_test(1);
do_test(2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment