Skip to content

Commit f163d10

Browse files
committed
perf(parser): tokens raw deserialization use Int32Array (#21137)
Continuation of #21132. Use `Int32Array` view of the buffer for tokens deserialization in `oxc-parser`.
1 parent 7a86613 commit f163d10

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

napi/parser/src-js/raw-transfer/eager.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ const IS_ESCAPED_FIELD_OFFSET = 10;
175175
* @returns {Object[]} - Array of token objects
176176
*/
177177
function deserializeTokens(buffer, sourceText, isJs) {
178-
const { uint32 } = buffer;
178+
const { int32 } = buffer;
179179

180-
let pos = uint32[TOKENS_OFFSET_POS_32];
181-
const len = uint32[TOKENS_LEN_POS_32];
180+
let pos = int32[TOKENS_OFFSET_POS_32];
181+
const len = int32[TOKENS_LEN_POS_32];
182182
const endPos = pos + len * TOKEN_SIZE;
183183

184184
const tokens = [];
@@ -198,11 +198,11 @@ function deserializeTokens(buffer, sourceText, isJs) {
198198
* @returns {Object} - Token object
199199
*/
200200
function deserializeToken(pos, buffer, sourceText, isJs) {
201-
const { uint32 } = buffer;
201+
const { int32 } = buffer;
202202

203203
const pos32 = pos >> 2;
204-
const start = uint32[pos32],
205-
end = uint32[pos32 + 1];
204+
const start = int32[pos32],
205+
end = int32[pos32 + 1];
206206

207207
let value = sourceText.slice(start, end);
208208

0 commit comments

Comments
 (0)