Skip to content

Commit

Permalink
[RUST][RUNTIME] Fix workspace (#5503)
Browse files Browse the repository at this point in the history
* [RUST][RUNTIME] Fix workspace

* use ok_or_else instead of ok_or
  • Loading branch information
kazum committed May 4, 2020
1 parent 6bbab4c commit 7e88030
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions rust/runtime/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl WorkspacePool {
.iter()
.fold(None, |cur_ws_idx: Option<usize>, &idx| {
let ws_size = self.workspaces[idx].size();
if !ws_size >= size {
if ws_size < size {
return cur_ws_idx;
}
cur_ws_idx.or(Some(idx)).and_then(|cur_idx| {
Expand Down Expand Up @@ -92,9 +92,8 @@ impl WorkspacePool {
break;
}
}
if let Some(ws_idx) = ws_idx {
self.free.push(ws_idx);
}
let ws_idx = ws_idx.ok_or_else(|| format_err!("Invalid pointer"))?;
self.free.push(ws_idx);
Ok(())
}
}
Expand Down Expand Up @@ -135,6 +134,5 @@ pub extern "C" fn TVMBackendFreeWorkspace(
Ok(()) => 0,
Err(_) => -1,
}) as c_int
});
0
})
}

0 comments on commit 7e88030

Please sign in to comment.