optimize memory.grow 0 (#443)
This commit is contained in:
@@ -80,6 +80,11 @@ impl LinearMemory {
|
|||||||
/// Returns `None` if memory can't be grown by the specified amount
|
/// Returns `None` if memory can't be grown by the specified amount
|
||||||
/// of wasm pages.
|
/// of wasm pages.
|
||||||
pub fn grow(&mut self, delta: u32) -> Option<u32> {
|
pub fn grow(&mut self, delta: u32) -> Option<u32> {
|
||||||
|
// Optimization of memory.grow 0 calls.
|
||||||
|
if delta == 0 {
|
||||||
|
return Some(self.current);
|
||||||
|
}
|
||||||
|
|
||||||
let new_pages = match self.current.checked_add(delta) {
|
let new_pages = match self.current.checked_add(delta) {
|
||||||
Some(new_pages) => new_pages,
|
Some(new_pages) => new_pages,
|
||||||
// Linear memory size overflow.
|
// Linear memory size overflow.
|
||||||
|
|||||||
Reference in New Issue
Block a user