From 2dd2ec38367a2fb5c0c3cd069386ef541f83e299 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 5 Dec 2020 11:56:34 +0100 Subject: [PATCH] v8: refactor to use more primordials PR-URL: https://github.com/nodejs/node/pull/36527 Reviewed-By: Rich Trott Reviewed-By: Pooja D P --- lib/v8.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/v8.js b/lib/v8.js index 0ca1103cee9c0e..f1c624bc10add0 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -17,6 +17,8 @@ const { Array, ArrayBuffer, + ArrayPrototypeForEach, + ArrayPrototypePush, DataView, Error, Float32Array, @@ -191,13 +193,14 @@ const arrayBufferViewTypeToIndex = new SafeMap(); { const dummy = new ArrayBuffer(); - for (const [i, ctor] of arrayBufferViewTypes.entries()) { + ArrayPrototypeForEach(arrayBufferViewTypes, (ctor, i) => { const tag = ObjectPrototypeToString(new ctor(dummy)); arrayBufferViewTypeToIndex.set(tag, i); - } + }); } -const bufferConstructorIndex = arrayBufferViewTypes.push(FastBuffer) - 1; +const bufferConstructorIndex = + ArrayPrototypePush(arrayBufferViewTypes, FastBuffer) - 1; class DefaultSerializer extends Serializer { constructor() {