Reduce allocations on project type detection (#32818)
Release Notes: - N/A
This commit is contained in:
parent
7fb8ae0024
commit
701fa4daa8
1 changed files with 15 additions and 8 deletions
|
@ -374,22 +374,28 @@ impl Telemetry {
|
|||
return None;
|
||||
}
|
||||
|
||||
let mut project_types: HashSet<String> = HashSet::new();
|
||||
let mut project_types: HashSet<&str> = HashSet::new();
|
||||
|
||||
for (path, _, _) in updated_entries_set.iter() {
|
||||
let Some(file_name) = path.file_name().and_then(|f| f.to_str()) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if file_name == "pnpm-lock.yaml" {
|
||||
project_types.insert("pnpm".to_string());
|
||||
let project_type = if file_name == "pnpm-lock.yaml" {
|
||||
Some("pnpm")
|
||||
} else if file_name == "yarn.lock" {
|
||||
project_types.insert("yarn".to_string());
|
||||
Some("yarn")
|
||||
} else if file_name == "package.json" {
|
||||
project_types.insert("node".to_string());
|
||||
Some("node")
|
||||
} else if DOTNET_PROJECT_FILES_REGEX.is_match(file_name) {
|
||||
project_types.insert("dotnet".to_string());
|
||||
}
|
||||
Some("dotnet")
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if let Some(project_type) = project_type {
|
||||
project_types.insert(project_type);
|
||||
};
|
||||
}
|
||||
|
||||
if !project_types.is_empty() {
|
||||
|
@ -398,7 +404,8 @@ impl Telemetry {
|
|||
.insert(worktree_id);
|
||||
}
|
||||
|
||||
let mut project_names_vec: Vec<String> = project_types.into_iter().collect();
|
||||
let mut project_names_vec: Vec<String> =
|
||||
project_types.into_iter().map(String::from).collect();
|
||||
project_names_vec.sort();
|
||||
Some(project_names_vec)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue