Simplify column look-up in default

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.
This commit is contained in:
sholderbach 2024-08-02 23:10:19 +02:00
parent af34d5c062
commit e62356f5ec

View File

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