From c9d8be0704adb4a4d6dc3320bd1880e831eb8ce6 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 31 Dec 2017 00:42:07 -0800 Subject: [PATCH] Use Ropey's reader to load from disk. Saves memory and is also faster. Win-win! --- src/buffer/mod.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/buffer/mod.rs b/src/buffer/mod.rs index 7933583..d3d1fb7 100644 --- a/src/buffer/mod.rs +++ b/src/buffer/mod.rs @@ -42,12 +42,8 @@ impl Buffer { } pub fn new_from_file(path: &Path) -> io::Result { - let mut f = BufReader::new(try!(File::open(path))); - let mut string = String::new(); - try!(f.read_to_string(&mut string)); - let buf = Buffer { - text: Rope::from_str(&string[..]), + text: Rope::from_reader(BufReader::new(try!(File::open(path))))?, file_path: Some(path.to_path_buf()), undo_stack: UndoStack::new(), };