Use slice::fill for filling tables.

Now that `slice::fill` is stable, update the table implementation in the
runtime to use it.
This commit is contained in:
Peter Huene
2021-02-18 10:23:57 -08:00
parent f170d0b328
commit f48d1e2be4

View File

@@ -180,30 +180,18 @@ impl Table {
} }
match val { match val {
TableElement::FuncRef(r) => { TableElement::FuncRef(r) => unsafe {
unsafe {
self.with_funcrefs_mut(move |elements| { self.with_funcrefs_mut(move |elements| {
let elements = elements.unwrap(); let elements = elements.unwrap();
elements[start as usize..end as usize].fill(r);
// TODO: replace this with slice::fill (https://github.com/rust-lang/rust/issues/70758) when stabilized
for e in &mut elements[start as usize..end as usize] {
*e = r;
}
}); });
} },
} TableElement::ExternRef(r) => unsafe {
TableElement::ExternRef(r) => {
unsafe {
self.with_externrefs_mut(move |elements| { self.with_externrefs_mut(move |elements| {
let elements = elements.unwrap(); let elements = elements.unwrap();
elements[start as usize..end as usize].fill(r);
// TODO: replace this with slice::fill (https://github.com/rust-lang/rust/issues/70758) when stabilized
for e in &mut elements[start as usize..end as usize] {
*e = r.clone();
}
}); });
} },
}
} }
Ok(()) Ok(())