mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
perf(parser): tokens raw deserialization use Int32Array (#21137)
Continuation of #21132. Use `Int32Array` view of the buffer for tokens deserialization in `oxc-parser`.
This commit is contained in:
1 parent
7a866138d1
commit
f163d10859
1 file changed
+6
-6
@@ -175,10 +175,10 @@ const IS_ESCAPED_FIELD_OFFSET = 10;
|
||||
* @returns {Object[]} - Array of token objects
|
||||
*/
|
||||
function deserializeTokens(buffer, sourceText, isJs) {
|
||||
const { uint32 } = buffer;
|
||||
const { int32 } = buffer;
|
||||
|
||||
let pos = uint32[TOKENS_OFFSET_POS_32];
|
||||
const len = uint32[TOKENS_LEN_POS_32];
|
||||
let pos = int32[TOKENS_OFFSET_POS_32];
|
||||
const len = int32[TOKENS_LEN_POS_32];
|
||||
const endPos = pos + len * TOKEN_SIZE;
|
||||
|
||||
const tokens = [];
|
||||
@@ -198,11 +198,11 @@ function deserializeTokens(buffer, sourceText, isJs) {
|
||||
* @returns {Object} - Token object
|
||||
*/
|
||||
function deserializeToken(pos, buffer, sourceText, isJs) {
|
||||
const { uint32 } = buffer;
|
||||
const { int32 } = buffer;
|
||||
|
||||
const pos32 = pos >> 2;
|
||||
const start = uint32[pos32],
|
||||
end = uint32[pos32 + 1];
|
||||
const start = int32[pos32],
|
||||
end = int32[pos32 + 1];
|
||||
|
||||
let value = sourceText.slice(start, end);
|
||||
|
||||
|
||||
Reference in new issue
Block a user