Change the elems parameter of declare_table_elements to a boxed slice.

Implementations that want a full `Vec` can use `into_vec` to convert it
back.
This commit is contained in:
Dan Gohman
2018-12-18 14:13:46 -08:00
parent 054e6fcf07
commit 7120633363
3 changed files with 9 additions and 4 deletions

View File

@@ -402,7 +402,7 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
_table_index: TableIndex,
_base: Option<GlobalIndex>,
_offset: usize,
_elements: Vec<FuncIndex>,
_elements: Box<[FuncIndex]>,
) {
// We do nothing
}

View File

@@ -14,8 +14,8 @@ use cranelift_codegen::ir::immediates::Offset32;
use cranelift_codegen::ir::{self, InstBuilder};
use cranelift_codegen::isa::TargetFrontendConfig;
use failure_derive::Fail;
use std::boxed::Box;
use std::convert::From;
use std::vec::Vec;
use wasmparser::BinaryReaderError;
/// The value of a WebAssembly global variable.
@@ -336,7 +336,7 @@ pub trait ModuleEnvironment<'data> {
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Vec<FuncIndex>,
elements: Box<[FuncIndex]>,
);
/// Provides the contents of a function body.

View File

@@ -253,7 +253,12 @@ pub fn parse_element_section<'data>(
let x = item?;
elems.push(FuncIndex::from_u32(x));
}
environ.declare_table_elements(TableIndex::from_u32(table_index), base, offset, elems)
environ.declare_table_elements(
TableIndex::from_u32(table_index),
base,
offset,
elems.into_boxed_slice(),
)
}
Ok(())
}