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:
parent
af34d5c062
commit
e62356f5ec
|
@ -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) {
|
||||||
|
if matches!(val, Value::Nothing { .. }) {
|
||||||
for (col, val) in record.to_mut().iter_mut() {
|
*val = value.clone();
|
||||||
if *col == column.item {
|
|
||||||
found = true;
|
|
||||||
if matches!(val, Value::Nothing { .. }) {
|
|
||||||
*val = value.clone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if !found {
|
|
||||||
record.to_mut().push(column.item.clone(), value.clone());
|
record.to_mut().push(column.item.clone(), value.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user