From 54b82760cdd7e39608f2da69d350bb9e37e1b5d7 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Mon, 1 Apr 2019 18:02:46 -0700 Subject: [PATCH] Switch 'rojo build' to use BufWriter, magic performance increase --- CHANGELOG.md | 2 ++ server/src/commands/build.rs | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dc4fe4c..234a8cbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Rojo Changelog ## [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) * Added support for a bunch of new types when dealing with XML model/place files: diff --git a/server/src/commands/build.rs b/server/src/commands/build.rs index 16301ed3..8a65387f 100644 --- a/server/src/commands/build.rs +++ b/server/src/commands/build.rs @@ -1,7 +1,7 @@ use std::{ path::PathBuf, fs::File, - io, + io::{self, Write, BufWriter}, }; use log::info; @@ -92,7 +92,7 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> { let mut imfs = Imfs::new(); imfs.add_roots_from_project(&project)?; 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 { OutputKind::Rbxmx => { @@ -121,5 +121,7 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> { }, } + file.flush()?; + Ok(()) } \ No newline at end of file