Skip to content

Commit

Permalink
Perform clippy and remove a lot of little things
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Dec 11, 2024
1 parent c2a63b8 commit 3201f37
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 28 deletions.
6 changes: 0 additions & 6 deletions core/engine/src/builtins/array_buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,6 @@ impl ArrayBuffer {
};

// 26. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, newLen).
let first = first;
let new_len = new_len;
to_buf[..new_len].copy_from_slice(&from_buf[first..first + new_len]);
}

Expand Down Expand Up @@ -933,10 +931,6 @@ pub(crate) fn create_byte_data_block(

// 1. Let db be a new Data Block value consisting of size bytes. If it is impossible to
// create such a Data Block, throw a RangeError exception.
let alloc_size = alloc_size.try_into().map_err(|e| {
JsNativeError::range().with_message(format!("couldn't allocate the data block: {e}"))
})?;

let mut data_block = Vec::new();
data_block.try_reserve_exact(alloc_size).map_err(|e| {
JsNativeError::range().with_message(format!("couldn't allocate the data block: {e}"))
Expand Down
7 changes: 0 additions & 7 deletions core/engine/src/builtins/array_buffer/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ impl SharedArrayBuffer {
)
.into());
}
let new_byte_len = new_byte_len;

// If we used let-else above to avoid the expect, we would carry a borrow through the `to_index`
// call, which could mutably borrow. Another alternative would be to clone the whole
Expand Down Expand Up @@ -448,8 +447,6 @@ impl SharedArrayBuffer {
.into());
}

let new_len = new_len;

// 20. Let fromBuf be O.[[ArrayBufferData]].
let from_buf = &buf.bytes_with_len(len)[first..];

Expand Down Expand Up @@ -563,10 +560,6 @@ pub(crate) fn create_shared_byte_data_block(

// 1. Let db be a new Shared Data Block value consisting of size bytes. If it is impossible to
// create such a Shared Data Block, throw a RangeError exception.
let size = size.try_into().map_err(|e| {
JsNativeError::range().with_message(format!("couldn't allocate the data block: {e}"))
})?;

if size == 0 {
// Must ensure we don't allocate a zero-sized buffer.
return Ok(Box::default());
Expand Down
6 changes: 0 additions & 6 deletions core/engine/src/builtins/typed_array/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1816,9 +1816,6 @@ impl BuiltinTypedArray {
// 19. If SameValue(srcBuffer, targetBuffer) is true or sameSharedArrayBuffer is true, then
let src_byte_index = if BufferObject::equals(&src_buf_obj, &target_buf_obj) {
// a. Let srcByteLength be source.[[ByteLength]].
let src_byte_offset = src_byte_offset;
let src_byte_length = src_byte_length;

let s = {
let slice = src_buf_obj.as_buffer();
let slice = slice
Expand Down Expand Up @@ -1859,8 +1856,6 @@ impl BuiltinTypedArray {

// 24. If srcType is the same as targetType, then
if src_type == target_type {
let src_byte_index = src_byte_index;
let target_byte_index = target_byte_index;
let byte_count = target_element_size * src_length;

// a. NOTE: If srcType and targetType are the same, the transfer must be performed in a manner that preserves the bit-level encoding of the source data.
Expand Down Expand Up @@ -2895,7 +2890,6 @@ impl BuiltinTypedArray {
.into());
}

let src_element_size = src_element_size;
let target_element_size = element_size;

// c. Let srcByteIndex be srcByteOffset.
Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/object/builtins/jsdataview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl JsDataView {

// 11. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
// 12. Set bufferByteLength to ArrayBufferByteLength(buffer, seq-cst).
let Some(buf_byte_len) = buffer.borrow().data.bytes().map(|s| s.len()) else {
let Some(buf_byte_len) = buffer.borrow().data.bytes().map(<[u8]>::len) else {
return Err(JsNativeError::typ()
.with_message("ArrayBuffer is detached")
.into());
Expand Down
8 changes: 0 additions & 8 deletions core/engine/src/value/conversions/try_from_js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ where
let length = object
.get(js_string!("length"), context)?
.to_length(context)?;
let length = match usize::try_from(length) {
Ok(length) => length,
Err(e) => {
return Err(JsNativeError::typ()
.with_message(format!("could not convert length to usize: {e}"))
.into());
}
};
let mut vec = Vec::with_capacity(length);
for i in 0..length {
let value = object.get(i, context)?;
Expand Down

0 comments on commit 3201f37

Please sign in to comment.