matthias-t/workspace

workspace::get should not iterate all workspaces

Closed this issue · 0 comments

My fault, sorry.

pub fn get(name: &str) -> Option<Workspace> {
paths()
.into_iter()
.filter(|path| {
let file_stem = path.file_stem();
if file_stem.is_none() {
return false;
}
file_stem.unwrap().to_string_lossy() == name
})
.map(read)
.map(parse)
.nth(0)
}

Instead it should only try to read from ~/workspace/NAME.toml. That implies moving workspace::Workspace::data_path(&self) to something like workspace::file_path(name: &str).