Skip to content

Commit

Permalink
FIX: Small de-bloat change in arrayformat
Browse files Browse the repository at this point in the history
Use for loop instead of .try_for_each; the latter produces a lot more
code (unoptimized) and is unnecessary in this instance.
  • Loading branch information
bluss committed Sep 30, 2019
1 parent 277e49b commit ad3340a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/arrayformat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,23 @@ fn format_with_overflow(
// no-op
} else if length <= limit {
fmt_elem(f, 0)?;
(1..length).try_for_each(|i| {
for i in 1..length {
f.write_str(separator)?;
fmt_elem(f, i)
})?;
fmt_elem(f, i)?
}
} else {
let edge = limit / 2;
fmt_elem(f, 0)?;
(1..edge).try_for_each(|i| {
for i in 1..edge {
f.write_str(separator)?;
fmt_elem(f, i)
})?;
fmt_elem(f, i)?;
}
f.write_str(separator)?;
f.write_str(ellipsis)?;
(length - edge..length).try_for_each(|i| {
for i in length - edge..length {
f.write_str(separator)?;
fmt_elem(f, i)
})?;
fmt_elem(f, i)?
}
}
Ok(())
}
Expand Down

0 comments on commit ad3340a

Please sign in to comment.