Skip to content

Commit c1478dd

Browse files
committed
perf boost
1 parent b90ed08 commit c1478dd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/runner/api.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::path::Path;
44
use crate::ownership::FileOwner;
55
use crate::project::Team;
66

7-
use super::{Error, ForFileResult, RunConfig, RunResult, Runner, config_from_path, run};
7+
use super::{Error, ForFileResult, RunConfig, RunResult, config_from_path, run};
88

99
pub fn for_file(run_config: &RunConfig, file_path: &str, from_codeowners: bool, json: bool) -> RunResult {
1010
if from_codeowners {
@@ -37,10 +37,17 @@ pub fn crosscheck_owners(run_config: &RunConfig) -> RunResult {
3737
run(run_config, |runner| runner.crosscheck_owners())
3838
}
3939

40+
// Returns all owners for a file without creating a Runner (performance optimized)
41+
pub fn owners_for_file(run_config: &RunConfig, file_path: &str) -> error_stack::Result<Vec<FileOwner>, Error> {
42+
let config = config_from_path(&run_config.config_path)?;
43+
use crate::ownership::file_owner_resolver::find_file_owners;
44+
let owners = find_file_owners(&run_config.project_root, &config, std::path::Path::new(file_path)).map_err(Error::Io)?;
45+
Ok(owners)
46+
}
47+
4048
// Returns the highest priority owner for a file. More to come here.
4149
pub fn file_owner_for_file(run_config: &RunConfig, file_path: &str) -> error_stack::Result<Option<FileOwner>, Error> {
42-
let runner = Runner::new(run_config)?;
43-
let owners = runner.owners_for_file(file_path)?;
50+
let owners = owners_for_file(run_config, file_path)?;
4451
Ok(owners.first().cloned())
4552
}
4653

0 commit comments

Comments
 (0)