From 1551b40d0199b80d99cc0d031cad61e5ead419cb 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 f4fe88346b0b63..1dc3cb394963ab 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -17,6 +17,8 @@ const { Array, ArrayBuffer, + ArrayPrototypeForEach, + ArrayPrototypePush, DataView, Error, Float32Array, @@ -185,13 +187,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() {