Skip to content

Conversation

@karthiknadig
Copy link
Member

For 187

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances symlink handling in the create_unknown_env function to improve Windows compatibility, specifically for tools like Scoop that use shim executables. The change combines symlinks from the ResolvedPythonEnv (which includes the original executable and resolved paths from spawning Python) with additional symlinks discovered by scanning the bin directory.

Changes:

  • Modified create_unknown_env to merge symlinks from ResolvedPythonEnv with those found by find_symlinks
  • Added deduplication and sorting of the combined symlinks to ensure consistency
Comments suppressed due to low confidence (1)

crates/pet/src/locators.rs:179

  • The contains check on line 175 performs a linear search through the vector for each symlink, resulting in O(n²) complexity when merging large lists. Consider using a HashSet for deduplication or using extend followed by sorting and dedup() for better performance.
    if let Some(additional_symlinks) = find_symlinks(&resolved_env.executable) {
        for symlink in additional_symlinks {
            if !symlinks.contains(&symlink) {
                symlinks.push(symlink);
            }
        }
    }

Comment on lines +180 to +181
symlinks.sort();
symlinks.dedup();
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dedup() call after sort() is redundant because the code already checks if !symlinks.contains(&symlink) before adding each symlink at line 175. This means duplicates are already prevented during the merge. Consider removing the dedup() call for better performance, or remove the contains check and rely solely on dedup() after sorting.

This issue also appears in the following locations of the same file:

  • line 173

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants