Switch 'rojo build' to use BufWriter, magic performance increase

This commit is contained in:
Lucien Greathouse
2019-04-01 18:02:46 -07:00
parent 77f79fa913
commit 54b82760cd
2 changed files with 6 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
# Rojo Changelog # Rojo Changelog
## [Unreleased] ## [Unreleased]
* Changed `rojo build` to use buffered I/O, which can make it up to 2x faster in some cases.
* Building [*Road Not Taken*](https://github.com/LPGhatguy/roads) to an `rbxlx` file dropped from 150ms to 70ms on my machine
## [0.5.0 Alpha 8](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.8) (March 29, 2019) ## [0.5.0 Alpha 8](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.8) (March 29, 2019)
* Added support for a bunch of new types when dealing with XML model/place files: * Added support for a bunch of new types when dealing with XML model/place files:

View File

@@ -1,7 +1,7 @@
use std::{ use std::{
path::PathBuf, path::PathBuf,
fs::File, fs::File,
io, io::{self, Write, BufWriter},
}; };
use log::info; use log::info;
@@ -92,7 +92,7 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
let mut imfs = Imfs::new(); let mut imfs = Imfs::new();
imfs.add_roots_from_project(&project)?; imfs.add_roots_from_project(&project)?;
let tree = construct_oneoff_tree(&project, &imfs)?; let tree = construct_oneoff_tree(&project, &imfs)?;
let mut file = File::create(&options.output_file)?; let mut file = BufWriter::new(File::create(&options.output_file)?);
match output_kind { match output_kind {
OutputKind::Rbxmx => { OutputKind::Rbxmx => {
@@ -121,5 +121,7 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
}, },
} }
file.flush()?;
Ok(()) Ok(())
} }