Skip to content

Commit

Permalink
implement clippy collapsible if else suggestion; microoptimize temp_v…
Browse files Browse the repository at this point in the history
…al assignment
  • Loading branch information
jqnatividad committed Jun 26, 2024
1 parent ec9cd71 commit cd44da1
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1719,12 +1719,10 @@ pub fn write_json(
.map(|(col_idx, b)| {
if no_headers {
col_idx.to_string()
} else if let Ok(val) = simdutf8::basic::from_utf8(b) {
val.to_owned()
} else {
if let Ok(val) = simdutf8::basic::from_utf8(b) {
val.to_owned()
} else {
String::from_utf8_lossy(b).to_string()
}
String::from_utf8_lossy(b).to_string()
}
})
.collect();
Expand All @@ -1747,11 +1745,11 @@ pub fn write_json(
}
write!(json_wtr, "{{")?;
for (idx, b) in record.iter().enumerate() {
if let Ok(val) = simdutf8::basic::from_utf8(b) {
temp_val = val.to_owned();
temp_val = if let Ok(val) = simdutf8::basic::from_utf8(b) {
val.to_owned()
} else {
temp_val = String::from_utf8_lossy(b).to_string();
}
String::from_utf8_lossy(b).to_string()
};
if temp_val.is_empty() {
temp_val.clone_from(&null_val);
} else {
Expand Down

0 comments on commit cd44da1

Please sign in to comment.