@@ -35,6 +35,8 @@ pub struct ProjectBuilder<'a> {
3535 pub codeowners_file_path : PathBuf ,
3636}
3737
38+ const INITIAL_VECTOR_CAPACITY : usize = 1000 ;
39+
3840impl < ' a > ProjectBuilder < ' a > {
3941 pub fn new ( config : & ' a Config , base_path : PathBuf , codeowners_file_path : PathBuf ) -> Self {
4042 Self {
@@ -46,10 +48,10 @@ impl<'a> ProjectBuilder<'a> {
4648
4749 #[ instrument( level = "debug" , skip_all) ]
4850 pub fn build ( & mut self ) -> Result < Project , Error > {
49- let mut entry_types = Vec :: new ( ) ;
51+ let mut entry_types = Vec :: with_capacity ( INITIAL_VECTOR_CAPACITY ) ;
5052
5153 let mut builder = WalkBuilder :: new ( & self . base_path ) ;
52- builder. hidden ( false ) ;
54+ builder. hidden ( false ) . threads ( num_cpus :: get ( ) ) ;
5355 let walkdir = builder. build ( ) ;
5456
5557 for entry in walkdir {
@@ -101,7 +103,7 @@ impl<'a> ProjectBuilder<'a> {
101103 . fold (
102104 || {
103105 (
104- Vec :: < ProjectFile > :: new ( ) ,
106+ Vec :: < ProjectFile > :: with_capacity ( INITIAL_VECTOR_CAPACITY ) ,
105107 Vec :: < Package > :: new ( ) ,
106108 Vec :: < VendoredGem > :: new ( ) ,
107109 Vec :: < DirectoryCodeownersFile > :: new ( ) ,
@@ -223,7 +225,6 @@ fn build_project_file(path: PathBuf) -> ProjectFile {
223225 } ;
224226
225227 let first_line = content. lines ( ) . next ( ) ;
226-
227228 let Some ( first_line) = first_line else {
228229 return ProjectFile { path, owner : None } ;
229230 } ;
0 commit comments