mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 01:24:58 +02:00
Reduce again the number of match calls (#7815)
- Reduce the number of match calls (see commit messages) - A few miscellaneous improvements
This commit is contained in:
@ -67,15 +67,16 @@ fn nu_protocol_value_to_json(
|
||||
let mut used_cols: Option<&[String]> = None;
|
||||
for val in &vals {
|
||||
match val {
|
||||
Value::Record { cols, .. } => match &used_cols {
|
||||
Some(_cols) => {
|
||||
Value::Record { cols, .. } => {
|
||||
if let Some(_cols) = &used_cols {
|
||||
if _cols != cols {
|
||||
used_cols = None;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
used_cols = Some(cols)
|
||||
}
|
||||
None => used_cols = Some(cols),
|
||||
},
|
||||
}
|
||||
_ => {
|
||||
used_cols = None;
|
||||
break;
|
||||
|
@ -574,15 +574,14 @@ impl Peaker for PriorityMax {
|
||||
|
||||
fn peak(&mut self, _: &[usize], widths: &[usize]) -> Option<usize> {
|
||||
let col = (0..widths.len()).rev().max_by_key(|&i| widths[i]);
|
||||
match col {
|
||||
Some(col) => {
|
||||
if widths[col] == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(col)
|
||||
}
|
||||
if let Some(col) = col {
|
||||
if widths[col] == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(col)
|
||||
}
|
||||
None => None,
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user