Skip to content

Commit

Permalink
Simplify some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
js2xxx committed Feb 5, 2025
1 parent 12f695c commit dcb16a4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 29 deletions.
61 changes: 37 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<'a, A: Allocator> Session<'a, A> {
let iter = (0..BATCH_SIZE).map(|index| {
let size = 64;
let mut vec = Vec::with_capacity_in(size, self.alloc);
vec.extend(iter::repeat(index as u8).take(size.min(128)));
vec.extend(iter::repeat_n(index as u8, size.min(128)));
vec.into_boxed_slice()
});
let mut vec = Vec::with_capacity_in(BATCH_SIZE, self.alloc);
Expand Down
2 changes: 1 addition & 1 deletion examples/random2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn warm_up<'a, A: Allocator>(array: &mut [Option<Vec<u8, &'a A>>], a: &'a A) {

fn new_vec<A: Allocator>(size: usize, a: A) -> Vec<u8, A> {
let mut v = Vec::with_capacity_in(size, a);
v.extend(iter::repeat(0).take(size));
v.extend(iter::repeat_n(0, size));
v
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ mod test {

const CHUNK_SIZE: usize = 1024;
fn chunks(size: usize) -> impl Iterator<Item = [u8; CHUNK_SIZE]> {
iter::repeat([0u8; CHUNK_SIZE]).take(size / CHUNK_SIZE)
iter::repeat_n([0u8; CHUNK_SIZE], size / CHUNK_SIZE)
}

#[test]
Expand Down Expand Up @@ -257,8 +257,8 @@ mod test {
fn multithread() {
let j = thread::spawn(move || {
let mut vec = Vec::new_in(Ferroc);
vec.extend(iter::repeat(0u8).take(100));
vec.extend(iter::repeat(1u8).take(100));
vec.extend(iter::repeat_n(0u8, 100));
vec.extend(iter::repeat_n(1u8, 100));
vec
});
let vec = j.join().unwrap();
Expand Down

0 comments on commit dcb16a4

Please sign in to comment.