Skip to content

Commit 99b4164

Browse files
committed
refactor to use mem take
1 parent 4c0122e commit 99b4164

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/compute/src/render/reduce.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,24 +2345,22 @@ mod monoids {
23452345
}
23462346
}
23472347

2348-
// WARNING: Panics if self and source are of different `ReductionMonoid` enum entries.
23492348
fn clone_from(&mut self, source: &Self) {
23502349
use ReductionMonoid::*;
2351-
match (self, source) {
2352-
(Min(row), Min(source_row)) => {
2353-
row.clone_from(source_row);
2354-
}
2355-
(Max(row), Max(source_row)) => {
2356-
row.clone_from(source_row);
2357-
}
2358-
// FIXME(ptravers): not sure what we want to do here we can't overwrite
2359-
// without having owned access to the Row in dest. I don't see a way to
2360-
// achieve that without a clone. Is it better to panic or clone? I would lean
2361-
// clone for safety but I don't know how likely it is to hit the sad case
2362-
// in practice?
2363-
(dest, src) => soft_panic_or_log!(
2364-
"Mismatched monoid variants in clone_from! destination: {dest:?} source: {src:?}",
2365-
),
2350+
2351+
let mut row = match std::mem::take(self) {
2352+
Min(row) | Max(row) => row,
2353+
};
2354+
2355+
let source_row = match source {
2356+
Min(row) | Max(row) => row,
2357+
};
2358+
2359+
row.clone_from(source_row);
2360+
2361+
match source {
2362+
Min(_) => *self = Min(row),
2363+
Max(_) => *self = Max(row),
23662364
}
23672365
}
23682366
}

0 commit comments

Comments
 (0)