Skip to content

Commit 0d200e4

Browse files
authored
Improving project build speed (#44)
* improving project build speed * initializing vectors with capacity
1 parent c472ed8 commit 0d200e4

File tree

7 files changed

+300
-211
lines changed

7 files changed

+300
-211
lines changed

Cargo.lock

Lines changed: 27 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ debug = true
1010
clap = { version = "4.5.20", features = ["derive"] }
1111
clap_derive = "4.5.18"
1212
error-stack = "0.5.0"
13-
glob-match = "0.2.1"
13+
fast-glob = "0.4.0"
1414
ignore = "0.4.23"
1515
itertools = "0.13.0"
1616
path-clean = "1.0.1"
17+
lazy_static = "1.5.0"
18+
num_cpus = "1.16.0"
1719
rayon = "1.10.0"
1820
regex = "1.11.1"
1921
serde = { version = "1.0.214", features = ["derive"] }

src/common_test.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub mod tests {
1010

1111
use tempfile::tempdir;
1212

13-
use crate::{ownership::Ownership, project::Project};
13+
use crate::{ownership::Ownership, project_builder::ProjectBuilder};
1414

1515
macro_rules! ownership {
1616
($($test_files:expr),+) => {{
@@ -110,13 +110,15 @@ pub mod tests {
110110
let config = serde_yaml::from_reader(config_file)?;
111111

112112
let codeowners_file_path = &test_config.temp_dir_path.join(".github/CODEOWNERS");
113-
let project = Project::build(&test_config.temp_dir_path, codeowners_file_path, &config)?;
113+
let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone());
114+
let project = builder.build()?;
114115
let ownership = Ownership::build(project);
115116
if test_config.generate_codeowners {
116117
std::fs::write(codeowners_file_path, ownership.generate_file())?;
117118
}
118119
// rebuild project to ensure new codeowners file is read
119-
let project = Project::build(&test_config.temp_dir_path, codeowners_file_path, &config)?;
120+
let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone());
121+
let project = builder.build()?;
120122
Ok(Ownership::build(project))
121123
}
122124

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use ownership::{FileOwner, Ownership};
22

3-
use crate::project::Project;
3+
use crate::project_builder::ProjectBuilder;
44
use clap::{Parser, Subcommand};
55
use core::fmt;
66
use error_stack::{Context, Result, ResultExt};
@@ -15,6 +15,7 @@ mod common_test;
1515
mod config;
1616
mod ownership;
1717
mod project;
18+
mod project_builder;
1819

1920
#[derive(Subcommand, Debug)]
2021
enum Command {
@@ -114,7 +115,9 @@ fn cli() -> Result<(), Error> {
114115

115116
let config = serde_yaml::from_reader(config_file).change_context(Error::Io)?;
116117

117-
let ownership = Ownership::build(Project::build(&project_root, &codeowners_file_path, &config).change_context(Error::Io)?);
118+
let mut builder = ProjectBuilder::new(&config, project_root, codeowners_file_path.clone());
119+
let project = builder.build().change_context(Error::Io)?;
120+
let ownership = Ownership::build(project);
118121

119122
match args.command {
120123
Command::Validate => ownership.validate().change_context(Error::ValidationFailed)?,

src/ownership/mapper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use glob_match::glob_match;
1+
use fast_glob::glob_match;
22
use std::{
33
collections::HashMap,
44
fmt::{self, Display},

0 commit comments

Comments
 (0)