summaryrefslogtreecommitdiff
path: root/core/shared_queue.rs
diff options
context:
space:
mode:
authorKNnut <9387720+KNnut@users.noreply.github.com>2020-11-13 06:17:31 +0800
committerGitHub <noreply@github.com>2020-11-13 09:17:31 +1100
commit2c8439bc1e8118225c8ba4d64658c1c6b2182937 (patch)
treec3dde90a1bfbc2aba0bf993af8dc58d49444d1a4 /core/shared_queue.rs
parenta52d8839218e75311384fa8095d4cfde533ad923 (diff)
refactor(cli+core): various cleanups in Rust (#8336)
Diffstat (limited to 'core/shared_queue.rs')
-rw-r--r--core/shared_queue.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/core/shared_queue.rs b/core/shared_queue.rs
index e8ac30ebc..715fb4395 100644
--- a/core/shared_queue.rs
+++ b/core/shared_queue.rs
@@ -42,9 +42,7 @@ pub struct SharedQueue {
impl SharedQueue {
pub fn new(len: usize) -> Self {
- let mut buf = Vec::new();
- buf.resize(HEAD_INIT + len, 0);
- let buf = buf.into_boxed_slice();
+ let buf = vec![0; HEAD_INIT + len].into_boxed_slice();
let buf = v8::SharedArrayBuffer::new_backing_store_from_boxed_slice(buf);
let mut q = Self {
buf: buf.make_shared(),
@@ -263,9 +261,7 @@ mod tests {
}
fn alloc_buf(byte_length: usize) -> Box<[u8]> {
- let mut v = Vec::new();
- v.resize(byte_length, 0);
- v.into_boxed_slice()
+ vec![0; byte_length].into_boxed_slice()
}
#[test]