@@ -96,25 +96,19 @@ fn write_line<W: std::io::Write>(
9696 None => input_line,
9797 } ;
9898 let buffer_output = !matches ! ( options. invalid, InvalidModes :: Abort ) ;
99- let mut formatted_line = Vec :: new ( ) ;
100- let handled_line = {
101- let output: & mut dyn std:: io:: Write = if buffer_output {
102- & mut formatted_line
103- } else {
104- writer
105- } ;
99+ let mut buf = Vec :: new ( ) ;
100+ let output: & mut dyn std:: io:: Write = if buffer_output { & mut buf } else { writer } ;
106101
107- if options. delimiter . is_some ( ) {
108- write_formatted_with_delimiter ( output, line, options, eol)
109- } else {
110- // Whitespace mode requires valid UTF-8
111- match std:: str:: from_utf8 ( line) {
112- Ok ( s) => write_formatted_with_whitespace ( output, s, options, eol) ,
113- Err ( _) => Err ( translate ! (
114- "numfmt-error-invalid-number" ,
115- "input" => escape_line( line) . quote( )
116- ) ) ,
117- }
102+ let handled_line = if options. delimiter . is_some ( ) {
103+ write_formatted_with_delimiter ( output, line, options, eol)
104+ } else {
105+ // Whitespace mode requires valid UTF-8
106+ match std:: str:: from_utf8 ( line) {
107+ Ok ( s) => write_formatted_with_whitespace ( output, s, options, eol) ,
108+ Err ( _) => Err ( translate ! (
109+ "numfmt-error-invalid-number" ,
110+ "input" => escape_line( line) . quote( )
111+ ) ) ,
118112 }
119113 } ;
120114
@@ -132,15 +126,14 @@ fn write_line<W: std::io::Write>(
132126 InvalidModes :: Ignore => { }
133127 }
134128 writer. write_all ( input_line) ?;
135-
136129 if let Some ( eol) = eol {
137130 writer. write_all ( & [ eol] ) ?;
138131 }
139132 return Ok ( true ) ;
140133 }
141134
142135 if buffer_output {
143- writer. write_all ( & formatted_line ) ?;
136+ writer. write_all ( & buf ) ?;
144137 }
145138 Ok ( false )
146139}
0 commit comments