Use env::var_os to read paths from the environment

This avoids unnecessary UTF-8 validation on OsStrings that we just pass
back to the OS.
This commit is contained in:
Matt Brubeck 2017-10-20 09:03:21 -07:00
parent fe16c1d5c3
commit c169f52b25
7 changed files with 19 additions and 18 deletions

View file

@ -77,9 +77,10 @@ pub fn default_config_dir() -> Option<PathBuf> {
#[cfg(target_os = "windows")]
pub fn default_config_dir() -> Option<PathBuf> {
let mut config_dir = match env::var("APPDATA") {
Ok(appdata_path) => PathBuf::from(appdata_path),
Err(_) => { let mut dir = env::home_dir().unwrap();
let mut config_dir = match env::var_os("APPDATA") {
Some(appdata_path) => PathBuf::from(appdata_path),
None => {
let mut dir = env::home_dir().unwrap();
dir.push("Appdata");
dir.push("Roaming");
dir