Repository: ouch-org/ouch (language: rust)

Issue:
use buffered output in `list` command
https://github.com/ouch-org/ouch/blob/b2d0ff75c89a1dd2d60938d0a490b320efcc1a43/src/list.rs#L35

All output to this file should be done with `BufWriter`.

(On top of that, `writeln!` shouldn't be mixed with `print!`, we should only use the former.)


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fe884aba..e44b061e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@ Categories Used:
 - Fix logging IO bottleneck [\#642](https://github.com/ouch-org/ouch/pull/642) ([AntoniosBarotsis](https://github.com/AntoniosBarotsis))
 - Support decompression  over stdin [\#692](https://github.com/ouch-org/ouch/pull/692) ([rcorre](https://github.com/rcorre))
 - Make `--format` more forgiving with the formatting of the provided format [\#519](https://github.com/ouch-org/ouch/pull/519) ([marcospb19](https://github.com/marcospb19))
+- Use buffered writer for list output [\#764](https://github.com/ouch-org/ouch/pull/764) ([killercup](https://github.com/killercup))
 
 ## [0.5.1](https://github.com/ouch-org/ouch/compare/0.5.0...0.5.1)
 
diff --git a/src/list.rs b/src/list.rs
index c065925b..8491798c 100644
--- a/src/list.rs
+++ b/src/list.rs
@@ -1,7 +1,7 @@
 //! Some implementation helpers related to the 'list' command.
 
 use std::{
-    io::{stdout, Write},
+    io::{stdout, BufWriter, Write},
     path::{Path, PathBuf},
 };
 
@@ -32,16 +32,16 @@ pub fn list_files(
     files: impl IntoIterator<Item = crate::Result<FileInArchive>>,
     list_options: ListOptions,
 ) -> crate::Result<()> {
-    let out = &mut stdout().lock();
+    let mut out = BufWriter::new(stdout().lock());
     let _ = writeln!(out, "Archive: {}", EscapedPathDisplay::new(archive));
 
     if list_options.tree {
         let tree = files.into_iter().collect::<crate::Result<Tree>>()?;
-        tree.print(out);
+        tree.print(&mut out);
     } else {
         for file in files {
             let FileInArchive { path, is_dir } = file?;
-            print_entry(out, EscapedPathDisplay::new(&path), is_dir);
+            print_entry(&mut out, EscapedPathDisplay::new(&path), is_dir);
         }
     }
     Ok(())
@@ -143,7 +143,7 @@ mod tree {
                 false => draw::FINAL_BRANCH,
             };
 
-            print!("{prefix}{final_part}");
+            let _ = write!(out, "{prefix}{final_part}");
             let is_dir = match self.file {
                 Some(FileInArchive { is_dir, .. }) => is_dir,
                 None => true,


Test patch: