Use Ropey's reader to load from disk.
Saves memory and is also faster. Win-win!
This commit is contained in:
parent
2da187ff5d
commit
c9d8be0704
|
@ -42,12 +42,8 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_from_file(path: &Path) -> io::Result<Buffer> {
|
pub fn new_from_file(path: &Path) -> io::Result<Buffer> {
|
||||||
let mut f = BufReader::new(try!(File::open(path)));
|
|
||||||
let mut string = String::new();
|
|
||||||
try!(f.read_to_string(&mut string));
|
|
||||||
|
|
||||||
let buf = Buffer {
|
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()),
|
file_path: Some(path.to_path_buf()),
|
||||||
undo_stack: UndoStack::new(),
|
undo_stack: UndoStack::new(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user