Skip to content

Commit

Permalink
Compute regex once in native locator (#23375)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed May 8, 2024
1 parent 91d23ef commit 3e20701
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion native_locator/src/homebrew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ pub fn find_and_report(
let homebrew_prefix = environment.get_env_var("HOMEBREW_PREFIX".to_string())?;
let homebrew_prefix_bin = PathBuf::from(homebrew_prefix).join("bin");
let mut reported: HashSet<String> = HashSet::new();
let python_regex = Regex::new(r"/(\d+\.\d+\.\d+)/").unwrap();
for file in std::fs::read_dir(homebrew_prefix_bin).ok()? {
if let Some(exe) = is_symlinked_python_executable(file) {
let python_regex = Regex::new(r"/(\d+\.\d+\.\d+)/").unwrap();
let python_version = exe.to_string_lossy().to_string();
let version = match python_regex.captures(&python_version) {
Some(captures) => match captures.get(1) {
Expand Down

0 comments on commit 3e20701

Please sign in to comment.