Simplify column look-up in default (#13522)

# Description
Since we make the promise that record keys/columns are exclusice we
don't have to go through all columns after we have found the first one.
Should permit some short-circuiting if the column is found early.

# User-Facing Changes
(-)

# Tests + Formatting
(-)
This commit is contained in:
Stefan Holderbach 2024-08-03 00:26:35 +02:00 committed by GitHub
parent af34d5c062
commit ff1ad77130
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -102,19 +102,13 @@ fn default(
val: ref mut record,
..
} => {
let mut found = false;
for (col, val) in record.to_mut().iter_mut() {
if *col == column.item {
found = true;
let record = record.to_mut();
if let Some(val) = record.get_mut(&column.item) {
if matches!(val, Value::Nothing { .. }) {
*val = value.clone();
}
}
}
if !found {
record.to_mut().push(column.item.clone(), value.clone());
} else {
record.push(column.item.clone(), value.clone());
}
item