remove inefficient update_positions
This commit is contained in:
parent
df4e671bc4
commit
b3e7ae7900
@ -123,23 +123,22 @@ impl Game {
|
|||||||
_ => (roll - 1, false),
|
_ => (roll - 1, false),
|
||||||
};
|
};
|
||||||
let dst_stack = right[dst_rel_idx].assume_stack_mut();
|
let dst_stack = right[dst_rel_idx].assume_stack_mut();
|
||||||
|
let dst_true_idx = src_sq + 1 + dst_rel_idx; // src_sq + 1 was the original split boundary, so add the relative index to that to get the true index
|
||||||
|
|
||||||
if prepend {
|
if prepend {
|
||||||
let slice_len = src_stack.len() - slice_start;
|
let slice_len = src_stack.len() - slice_start;
|
||||||
src_stack.move_slice_under(dst_stack, slice_start);
|
src_stack.move_slice_under(dst_stack, slice_start);
|
||||||
for i in 0..slice_len {
|
for i in 0..slice_len {
|
||||||
self.camels[dst_stack[i]] = src_sq + dst_rel_idx + 1;
|
self.camels[dst_stack[i]] = dst_true_idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let dst_prev_len = dst_stack.len();
|
let dst_prev_len = dst_stack.len();
|
||||||
src_stack.move_slice(dst_stack, slice_start);
|
src_stack.move_slice(dst_stack, slice_start);
|
||||||
for i in dst_prev_len..dst_stack.len() {
|
for i in dst_prev_len..dst_stack.len() {
|
||||||
self.camels[dst_stack[i]] = src_sq + dst_rel_idx + 1;
|
self.camels[dst_stack[i]] = dst_true_idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update_positions(dst_rel_idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dice[die] = true;
|
self.dice[die] = true;
|
||||||
@ -186,6 +185,6 @@ mod test {
|
|||||||
game.advance(Purple, 1);
|
game.advance(Purple, 1);
|
||||||
assert_eq!(game.dice[Purple], true);
|
assert_eq!(game.dice[Purple], true);
|
||||||
assert_eq!(game.squares[3].assume_stack(), &Stack::from([Red, Purple, Yellow]));
|
assert_eq!(game.squares[3].assume_stack(), &Stack::from([Red, Purple, Yellow]));
|
||||||
// B, _, G,
|
// B, _, G, RPY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user