Skip to content

refactor DataView, TypedArray, ArrayBuffer indices to use usize #4766

Description

@zhuzhu81998

The usage of u64 vs usize is not unified for indices of the types backed by ArrayBuffer.
We want to use usize wherever possible.

For example:

/// Returns the `byte_offset` field property of [`JsDataView`] as a u64 integer
#[inline]
pub fn byte_offset(&self, context: &mut Context) -> JsResult<u64> {
DataView::get_byte_offset(&self.inner.clone().upcast().into(), &[], context)
.map(|v| v.as_number().expect("byte_offset value must be a number") as u64)
}

/// The internal representation of an `ArrayBuffer` object.
#[derive(Debug, Clone, Trace, Finalize, JsData)]
pub struct ArrayBuffer {
/// The `[[ArrayBufferData]]` internal slot.
#[unsafe_ignore_trace]
data: Option<AlignedVec<u8>>,
/// The `[[ArrayBufferMaxByteLength]]` internal slot.
max_byte_len: Option<u64>,
/// The `[[ArrayBufferDetachKey]]` internal slot.
detach_key: JsValue,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions