From 3041e6ec78520f655f6650677778813383338fa7 Mon Sep 17 00:00:00 2001 From: ZiJian Liu Date: Fri, 18 Dec 2020 22:14:10 +0800 Subject: [PATCH] lib: refactor to use primordials in internal/freelist.js --- lib/internal/freelist.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/internal/freelist.js b/lib/internal/freelist.js index ac2b12c4d45a54..6366bc8f9d2002 100644 --- a/lib/internal/freelist.js +++ b/lib/internal/freelist.js @@ -1,6 +1,8 @@ 'use strict'; const { + ArrayPrototypePop, + ArrayPrototypePush, ReflectApply, } = primordials; @@ -14,13 +16,13 @@ class FreeList { alloc() { return this.list.length > 0 ? - this.list.pop() : + ArrayPrototypePop(this.list) : ReflectApply(this.ctor, this, arguments); } free(obj) { if (this.list.length < this.max) { - this.list.push(obj); + ArrayPrototypePush(this.list, obj); return true; } return false;