mirror of
https://github.com/nushell/nushell.git
synced 2024-11-28 11:24:09 +01:00
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:
parent
af34d5c062
commit
ff1ad77130
@ -102,19 +102,13 @@ fn default(
|
|||||||
val: ref mut record,
|
val: ref mut record,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let mut found = false;
|
let record = record.to_mut();
|
||||||
|
if let Some(val) = record.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 {
|
||||||
}
|
record.push(column.item.clone(), value.clone());
|
||||||
|
|
||||||
if !found {
|
|
||||||
record.to_mut().push(column.item.clone(), value.clone());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
item
|
item
|
||||||
|
Loading…
Reference in New Issue
Block a user