Skip to content

Editorial: Make better use of ValidateTypedArray #3634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gibson042
Copy link
Contributor

Split from #3629 as requested at #3629 (comment)

@@ -41197,8 +41197,7 @@ <h1>%ArrayIteratorPrototype%.next ( )</h1>
1. Let _index_ be _O_.[[ArrayLikeNextIndex]].
1. Let _kind_ be _O_.[[ArrayLikeIterationKind]].
1. If _array_ has a [[TypedArrayName]] internal slot, then
1. Let _taRecord_ be MakeTypedArrayWithBufferWitnessRecord(_array_, ~seq-cst~).
1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, throw a *TypeError* exception.
1. Let _taRecord_ be ? ValidateTypedArray(_array_, ~seq-cst~).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems worse to me. Every existing use of ValidateTypedArray is passed an object which is not yet known to be a TA.

I'd be OK with introducing a new AO for this - GetInBoundsTALengthWitness or something, maybe - and then using it ValidateTypedArray and in callsites such as this. But I really don't like re-using ValidateTypedArray for this.

1. Else,
1. Let _type_ be TypedArrayElementType(_typedArray_).
1. If IsUnclampedIntegerElementType(_type_) is *false* and IsBigIntElementType(_type_) is *false*, throw a *TypeError* exception.
1. Let _type_ be TypedArrayElementType(_typedArray_).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the else guard? There's no reason to do this check when _waitable_ is *true*, since it is implied by the checks in that branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants