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:
@@ -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(())
|
||||||
|
|||||||
Reference in New Issue
Block a user