Conversation
Replace the declarative search (SequenceSameValueZeroEqual) with an explicit naive linear search algorithm in TypedArraySearchSubsequence, with an editor note that implementations may use any equivalent algorithm (Boyer-Moore, two-way, etc.). Early break on inner loop mismatch. Split ToCompatibleTypedArrayElementList into two paths following the %TypedArray%.prototype.set precedent (SetTypedArrayFromTypedArray vs SetTypedArrayFromArrayLike): - TypedArraySubsequenceFromTypedArray: reads needle elements directly from the underlying buffer via GetValueFromBuffer. No user code is invoked; @@iterator is not called. Checks [[ContentType]] compatibility. - TypedArraySubsequenceFromIterable: the existing @@iterator path for non-TypedArray iterables (Arrays, generators, Sets, etc.). Methods dispatch based on [[TypedArrayName]] internal slot presence. Additional spec fixes from review: - ValidateIntegralNumber: use "integral Number" term instead of manual NaN + truncate checks (fixes ±Infinity gap, matches concat proposal) - Add "not generic" boilerplate to all three methods - Add early return when haystackLength is 0 - Fix searchLast degenerate clamping range [0, -1] for empty arrays - Add notes for empty-needle semantics and evaluation order Update README and TEST_CASES.md to reflect the two-path design.
|
The rendered spec for this PR is available at https://tc39.es/proposal-typedarray-findwithin/pr/9. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the declarative search (SequenceSameValueZeroEqual) with an explicit naive linear search algorithm in TypedArraySearchSubsequence, with an editor note that implementations may use any equivalent algorithm (Boyer-Moore, two-way, etc.). Early break on inner loop mismatch.
Remove the Needle-as-Iterable following committee discussion
Rename to
indexOfSequence/lastIndexOfSequenceRemove
containsTypedArraySubsequenceFromTypedArray: reads needle elements directly from the underlying buffer via GetValueFromBuffer. No user code is invoked; @@iterator is not called. Checks [[ContentType]] compatibility.
Methods dispatch based on [[TypedArrayName]] internal slot presence.
Update README and TEST_CASES.md to reflect the two-path design.