Skip to content

Commit 088d217

Browse files
authored
Merge pull request #2 from wasmerio/misc-code-gol
Simplify some code in table.rs
2 parents 56fe08a + 7759b24 commit 088d217

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

lib/runtime/src/table.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,10 @@ impl Table {
5151
/// Returns `None` if table can't be grown by the specified amount
5252
/// of elements.
5353
pub fn grow(&self, delta: u32) -> Option<u32> {
54-
let new_len = match self.size().checked_add(delta) {
55-
Some(len) => {
56-
if let Some(max) = self.maximum {
57-
if len > max {
58-
return None;
59-
}
60-
}
61-
len
62-
}
63-
None => {
64-
return None;
65-
}
66-
};
54+
let new_len = self.size().checked_add(delta)?;
55+
if self.maximum.map_or(false, |max| new_len > max) {
56+
return None;
57+
}
6758
self.vec.borrow_mut().resize(
6859
usize::try_from(new_len).unwrap(),
6960
VMCallerCheckedAnyfunc::default(),

0 commit comments

Comments
 (0)