Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ - Improve compile performance by removing redundant condition #35

Merged
merged 3 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ pub fn compile_file(
let jsx_mode_args = get_jsx_mode_args(&root_package);
let uncurried_args = get_uncurried_args(version, &package, &root_package);

let warning_args: Vec<String> = match package.bsconfig.warnings.to_owned() {
let warning_args: Vec<String> = match root_package.bsconfig.warnings.to_owned() {
None => vec![],
Some(warnings) => {
let warn_number = match warnings.number {
Expand All @@ -874,7 +874,7 @@ pub fn compile_file(

let warn_error = match warnings.error {
Some(bsconfig::Error::Catchall(true)) => {
vec!["-warn-error A".to_string()]
vec!["-warn-error".to_string(), "A".to_string()]
}
Some(bsconfig::Error::Qualified(errors)) => {
vec!["-warn-error".to_string(), errors.to_string()]
Expand Down Expand Up @@ -1203,7 +1203,7 @@ pub fn build(filter: &Option<regex::Regex>, path: &str) -> Result<BuildState, ()
timing_ast_elapsed.as_secs_f64()
);
println!("{}", &err);
clean::cleanup_after_build(&build_state, false);
clean::cleanup_after_build(&build_state);
return Err(());
}
}
Expand Down Expand Up @@ -1545,7 +1545,7 @@ pub fn build(filter: &Option<regex::Regex>, path: &str) -> Result<BuildState, ()

logs::finalize(&build_state.packages);
pb.finish();
clean::cleanup_after_build(&build_state, compile_errors.len() == 0);
clean::cleanup_after_build(&build_state);
if compile_errors.len() > 0 {
if helpers::contains_ascii_characters(&compile_warnings) {
println!("{}", &compile_warnings);
Expand Down
15 changes: 3 additions & 12 deletions src/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,7 @@ fn failed_to_parse(module: &Module) -> bool {
}
}

fn failed_to_compile(module: &Module, no_errors: bool) -> bool {
// also clean up dirty modules when the compile failed
if !no_errors && module.compile_dirty {
return true;
};

fn failed_to_compile(module: &Module) -> bool {
match &module.source_type {
SourceType::SourceFile(SourceFile {
implementation:
Expand All @@ -373,11 +368,7 @@ fn failed_to_compile(module: &Module, no_errors: bool) -> bool {
}
}

pub fn cleanup_after_build(build_state: &BuildState, no_errors: bool) {
// let failed_modules = all_modules
// .difference(&compiled_modules)
// .collect::<AHashSet<&String>>();

pub fn cleanup_after_build(build_state: &BuildState) {
build_state
.modules
.par_iter()
Expand All @@ -395,7 +386,7 @@ pub fn cleanup_after_build(build_state: &BuildState, no_errors: bool) {
_ => (),
}
}
if failed_to_compile(module, no_errors) {
if failed_to_compile(module) {
// only retain ast file if it compiled successfully, that's the only thing we check
// if we see a AST file, we assume it compiled successfully, so we also need to clean
// up the AST file if compile is not successful
Expand Down
Loading