Skip to content

Commit d08a916

Browse files
committed
Move debug assertion inside loop to remove loop duplication
1 parent 2b5a168 commit d08a916

File tree

1 file changed

+8
-10
lines changed
  • datafusion/physical-expr/src/expressions

1 file changed

+8
-10
lines changed

datafusion/physical-expr/src/expressions/case.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,21 +456,19 @@ impl ResultBuilder {
456456

457457
match &mut self.state {
458458
Partial { arrays, indices } => {
459-
// This is check is only active for debug config because the callers of this method,
460-
// `case_when_with_expr` and `case_when_no_expr`, already ensure that
461-
// they only calculate a value for each row at most once.
462-
#[cfg(debug_assertions)]
463-
for row_ix in row_indices.as_primitive::<UInt32Type>().values().iter() {
464-
if !indices[*row_ix as usize].is_none() {
465-
return internal_err!("Duplicate value for row {}", *row_ix);
466-
}
467-
}
468-
469459
let array_index = PartialResultIndex::try_new(arrays.len())?;
470460

471461
arrays.push(row_values);
472462

473463
for row_ix in row_indices.as_primitive::<UInt32Type>().values().iter() {
464+
// This is check is only active for debug config because the callers of this method,
465+
// `case_when_with_expr` and `case_when_no_expr`, already ensure that
466+
// they only calculate a value for each row at most once.
467+
#[cfg(debug_assertions)]
468+
if !indices[*row_ix as usize].is_none() {
469+
return internal_err!("Duplicate value for row {}", *row_ix);
470+
}
471+
474472
indices[*row_ix as usize] = array_index;
475473
}
476474
Ok(())

0 commit comments

Comments
 (0)