Skip to content

Commit

Permalink
review fixup: use while loop
Browse files Browse the repository at this point in the history
Signed-off-by: Harald Hoyer <harald@profian.com>
  • Loading branch information
haraldh committed Mar 1, 2022
1 parent c956a1a commit b959099
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/sys/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,15 @@ impl Selector {
_ => false,
}
};
if let Some(index) = subscriptions.iter().position(predicate) {

let mut ret = Err(io::ErrorKind::NotFound.into());

while let Some(index) = subscriptions.iter().position(predicate) {
subscriptions.swap_remove(index);
// We might have two subscriptions (read and write).
loop {
if let Some(index) = subscriptions.iter().position(predicate) {
subscriptions.swap_remove(index);
} else {
break;
}
}
Ok(())
} else {
Err(io::ErrorKind::NotFound.into())
ret = Ok(())
}

ret
}
}

Expand Down

0 comments on commit b959099

Please sign in to comment.