Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup host-lookup in driver code #95

Merged
merged 1 commit into from
Sep 18, 2024
Merged

Cleanup host-lookup in driver code #95

merged 1 commit into from
Sep 18, 2024

Conversation

jfrimmel
Copy link
Owner

The old code was very messy for multiple reasons: the code worked almost entirely with Vec<u8> (a.k.a. byte strings) instead of actual strings, and thus needed to perform all string operations by hand. The search was also linear (although the performance penalty is negligible in this case). Another bad thing is, that the code always executed the fallback path of querying rustc -vV even if the normal path would have worked (which are the majority of cases), therefore the code needed a redesign.

This PR pulls the search over a specific command output out into its own function and runs the primary path first and only runs the fallback path if necessary. This makes the code much easier to read and under- stand. The new function also works on strings, making its implementation much simpler.

The old code was very messy for multiple reasons: the code worked almost
entirely with `Vec<u8>` (a.k.a. byte strings) instead of actual strings,
and thus needed to perform all string operations by hand. The search was
also linear (although the performance penalty is negligible in this
case). Another bad thing is, that the code always executed the fallback
path of querying `rustc -vV` even if the normal path would have worked
(which are the majority of cases), therefore the code needed a redesign.

This PR pulls the search over a specific command output out into its own
function and runs the primary path first and only runs the fallback path
if necessary. This makes the code much easier to read and under- stand.
The new function also works on strings, making its implementation much
simpler.
@jfrimmel jfrimmel merged commit 1c7bba0 into master Sep 18, 2024
9 checks passed
@jfrimmel jfrimmel deleted the cleanup-driver branch September 18, 2024 19:35
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.

1 participant