clean
This commit is contained in:
@@ -11,10 +11,10 @@ fn extend_layers_test(depth: usize, expire: usize) {
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
const EXPIRE: usize = 4;
|
||||
let mut group = c.benchmark_group(format!("extend_layers (expire {})", EXPIRE));
|
||||
group.measurement_time(Duration::from_secs(60));
|
||||
group.sample_size(10000);
|
||||
group.measurement_time(Duration::from_secs(10));
|
||||
group.sample_size(1000);
|
||||
|
||||
for (depth, expire) in (2..6).zip([EXPIRE].into_iter().cycle()) {
|
||||
for (depth, expire) in (4..8).zip([EXPIRE].into_iter().cycle()) {
|
||||
// TODO! maybe somehow get throughput from `extend_layers`?
|
||||
// group.throughput(Throughput::Elements(depth as u64));
|
||||
group.bench_with_input(BenchmarkId::from_parameter(depth), &depth, |b, depth| {
|
||||
|
||||
12
src/board.rs
12
src/board.rs
@@ -73,7 +73,8 @@ fn gen_adj_lookup() -> PosMap<ChainCollection> {
|
||||
chains
|
||||
.iter()
|
||||
.flatten()
|
||||
.all(|(i, j)| (0..BOARD_SIZE).contains(i) && (0..BOARD_SIZE).contains(j)),
|
||||
.flat_map(|(i, j)| [i, j]) // flatten to just numbers
|
||||
.all(|x| (0..BOARD_SIZE).contains(x)),
|
||||
"chains go out-of-bounds"
|
||||
);
|
||||
|
||||
@@ -320,16 +321,15 @@ impl Board {
|
||||
ADJ_LOOKUP
|
||||
.get(i, j)
|
||||
.iter()
|
||||
.filter_map(move |chain| {
|
||||
let mut end_idx = None;
|
||||
.flat_map(move |chain| {
|
||||
for (idx, &(new_i, new_j)) in chain.into_iter().enumerate() {
|
||||
let piece = self.get(new_i, new_j)?;
|
||||
if piece == starting_color {
|
||||
end_idx = Some(idx);
|
||||
break;
|
||||
// SAFETY! get_unchecked is fine here because it's an index of itself, it's fine
|
||||
return Some(unsafe { chain.get_unchecked(..idx) });
|
||||
}
|
||||
}
|
||||
end_idx.and_then(|idx| chain.get(..idx))
|
||||
None
|
||||
})
|
||||
.flatten()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user