From ad3340a6ef939d361a7aa1082fe23d72cd2b32ae Mon Sep 17 00:00:00 2001 From: bluss Date: Mon, 30 Sep 2019 20:48:00 +0200 Subject: [PATCH] FIX: Small de-bloat change in arrayformat Use for loop instead of .try_for_each; the latter produces a lot more code (unoptimized) and is unnecessary in this instance. --- src/arrayformat.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/arrayformat.rs b/src/arrayformat.rs index d1b5ba7fb..a7203b38a 100644 --- a/src/arrayformat.rs +++ b/src/arrayformat.rs @@ -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(()) }