Skip to content

Commit c78dc52

Browse files
committed
Don't clone PathBufs
1 parent 1189281 commit c78dc52

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

vm/src/sysmodule.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,20 @@ pub fn make_module(vm: &VirtualMachine, module: PyObjectRef, builtins: PyObjectR
5757
let path_list = if cfg!(target_arch = "wasm32") {
5858
vec![]
5959
} else {
60-
fn get_paths<'a>(
61-
paths: &'a Option<std::ffi::OsString>,
62-
) -> impl Iterator<Item = std::path::PathBuf> + 'a {
63-
match paths {
64-
Some(paths) => env::split_paths(paths),
65-
None => env::split_paths(""),
66-
}
67-
}
60+
let get_paths = |paths| match paths {
61+
Some(paths) => env::split_paths(paths),
62+
None => env::split_paths(""),
63+
};
6864

6965
let rustpy_path = env::var_os("RUSTPYTHONPATH");
7066
let py_path = env::var_os("PYTHONPATH");
71-
get_paths(&rustpy_path)
72-
.chain(get_paths(&py_path))
67+
get_paths(rustpy_path.as_ref())
68+
.chain(get_paths(py_path.as_ref()))
7369
.map(|path| {
7470
ctx.new_str(
75-
path.to_str()
76-
.expect("PYTHONPATH isn't valid unicode")
77-
.to_string(),
71+
path.into_os_string()
72+
.into_string()
73+
.expect("PYTHONPATH isn't valid unicode"),
7874
)
7975
})
8076
.collect()

0 commit comments

Comments
 (0)