dircolors: remove unsafe#12228
Conversation
|
GNU testsuite comparison: |
|
Good work. This is exactly the kind of unsafe worth removing. I think most uses of |
|
I think |
|
Yeah, we should definitely do that instead of mutating the environment. Regardless of the unsafe aspect, mutating global environment state makes the code harder to reason about and can interfere with optimizations. |
21993e0 to
895f7ea
Compare
Merging this PR will improve performance by 13.71%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
| pub fn guess_syntax() -> OutputFmt { | ||
| match env::var("SHELL") { | ||
| Ok(ref s) if !s.is_empty() => { | ||
| pub fn guess_syntax(env: Option<OsString>) -> OutputFmt { |
There was a problem hiding this comment.
| pub fn guess_syntax(env: Option<OsString>) -> OutputFmt { | |
| pub fn guess_syntax<P: AsRef<Path>>(path: Option<P>) -> OutputFmt { |
We can make this more type-safe and avoid .into() at the call sites.
There was a problem hiding this comment.
Then x.as_os_str().is_empty() until path_is_empty is stabilised.
No description provided.