Skip to content

Commit dd0766b

Browse files
committed
Compute regex once in native locator (#23375)
1 parent 5168747 commit dd0766b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

native_locator/src/homebrew.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ pub fn find_and_report(
3030
let homebrew_prefix = environment.get_env_var("HOMEBREW_PREFIX".to_string())?;
3131
let homebrew_prefix_bin = PathBuf::from(homebrew_prefix).join("bin");
3232
let mut reported: HashSet<String> = HashSet::new();
33+
let python_regex = Regex::new(r"/(\d+\.\d+\.\d+)/").unwrap();
3334
for file in std::fs::read_dir(homebrew_prefix_bin).ok()? {
3435
if let Some(exe) = is_symlinked_python_executable(file) {
35-
let python_regex = Regex::new(r"/(\d+\.\d+\.\d+)/").unwrap();
3636
let python_version = exe.to_string_lossy().to_string();
3737
let version = match python_regex.captures(&python_version) {
3838
Some(captures) => match captures.get(1) {

0 commit comments

Comments
 (0)