transfer_region refactor 2

Remove `.checked_sub` where logic makes this unnecessary
This commit is contained in:
Emilia Allison 2025-01-18 12:52:39 -05:00
parent 5acae8ffde
commit 1ca011f69c
Signed by: emilia
GPG Key ID: 05D5D1107E5100A1
1 changed files with 6 additions and 6 deletions

View File

@ -297,12 +297,12 @@ impl TransferRegion {
let (s_ul, s_br) = let (s_ul, s_br) =
standardize_rectangle(&source_corners.0, &source_corners.1); standardize_rectangle(&source_corners.0, &source_corners.1);
let s_dims = ( let s_dims = (
s_br.row.checked_sub(s_ul.row).unwrap() + 1, s_br.row - s_ul.row + 1,
s_br.col.checked_sub(s_ul.col).unwrap() + 1, s_br.col - s_ul.col + 1,
); );
let d_dims = ( let d_dims = (
d_br.row.checked_sub(d_ul.row).unwrap() + 1, d_br.row - d_ul.row + 1,
d_br.col.checked_sub(d_ul.col).unwrap() + 1, d_br.col - d_ul.col + 1,
); );
let number_used_src_wells = ( let number_used_src_wells = (
// Number of used source wells // Number of used source wells
@ -341,8 +341,8 @@ impl TransferRegion {
.into_iter() .into_iter()
.filter(|Well { row: x, col: y }| { .filter(|Well { row: x, col: y }| {
// Compute row and column offsets once // Compute row and column offsets once
let row_offset = x.checked_sub(d_ul.row).unwrap(); let row_offset = x - d_ul.row;
let col_offset = y.checked_sub(d_ul.col).unwrap(); let col_offset = y - d_ul.col;
// Row position check // Row position check
let row_matches = row_offset % row_modulus let row_matches = row_offset % row_modulus