Skip to content

Commit

Permalink
Editorial: factor out SetUint8ArrayBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Jan 28, 2024
1 parent 43885de commit c766348
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,7 @@ <h1>Uint8Array.fromBase64Into ( _string_, _into_ [ , _options_ ] )</h1>
1. Let _written_ be the length of _bytes_.
1. NOTE: FromBase64 does not invoke any user code, so the ArrayBuffer backing _into_ cannot have been detached or shrunk.
1. Assert: _written__byteLength_.
1. Let _offset_ be _into_.[[ByteOffset]].
1. Let _index_ be 0.
1. Repeat, while _index_ < _written_,
1. Let _byte_ be _bytes_[_index_].
1. Let _byteIndexInBuffer_ be _index_ + _offset_.
1. Perform SetValueInBuffer(_into_.[[ViewedArrayBuffer]], _byteIndexInBuffer_, ~uint8~, 𝔽(_byte_), *true*, ~unordered~).
1. Set _index_ to _index_ + 1.
1. Perform SetUint8ArrayBytes(_into_, _bytes_).
1. Let _resultObject_ be OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_resultObject_, *"read"*, 𝔽(_result_.[[Read]])).
1. Perform ! CreateDataPropertyOrThrow(_resultObject_, *"written"*, 𝔽(_written_)).
Expand Down Expand Up @@ -131,13 +125,7 @@ <h1>Uint8Array.fromHexInto ( _string_, _into_ )</h1>
1. Let _written_ be the length of _bytes_.
1. NOTE: FromHex does not invoke any user code, so the ArrayBuffer backing _into_ cannot have been detached or shrunk.
1. Assert: _written__byteLength_.
1. Let _offset_ be _into_.[[ByteOffset]].
1. Let _index_ be 0.
1. Repeat, while _index_ < _written_,
1. Let _byte_ be _bytes_[_index_].
1. Let _byteIndexInBuffer_ be _index_ + _offset_.
1. Perform SetValueInBuffer(_into_.[[ViewedArrayBuffer]], _byteIndexInBuffer_, ~uint8~, 𝔽(_byte_), *true*, ~unordered~).
1. Set _index_ to _index_ + 1.
1. Perform SetUint8ArrayBytes(_into_, _bytes_).
1. Let _resultObject_ be OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_resultObject_, *"read"*, 𝔽(_result_.[[Read]])).
1. Perform ! CreateDataPropertyOrThrow(_resultObject_, *"written"*, 𝔽(_written_)).
Expand Down Expand Up @@ -183,6 +171,26 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-writeuint8arraybytes" type="abstract operation">
<h1>
SetUint8ArrayBytes (
_into_: a Uint8Array,
_bytes_: a List of byte values
): ~unused~
</h1>
<dl class="header"></dl>
<emu-alg>
1. Let _offset_ be _into_.[[ByteOffset]].
1. Let _len_ be the length of _bytes_.
1. Let _index_ be 0.
1. Repeat, while _index_ < _len_,
1. Let _byte_ be _bytes_[_index_].
1. Let _byteIndexInBuffer_ be _index_ + _offset_.
1. Perform SetValueInBuffer(_into_.[[ViewedArrayBuffer]], _byteIndexInBuffer_, ~uint8~, 𝔽(_byte_), *true*, ~unordered~).
1. Set _index_ to _index_ + 1.
</emu-alg>
</emu-clause>

<emu-clause id="sec-helpers">
<h1>Helpers</h1>

Expand Down

0 comments on commit c766348

Please sign in to comment.