From c9861a344a900db6a98ec13dfb56abfefcd1a3e8 Mon Sep 17 00:00:00 2001 From: Brian White Date: Sat, 26 Dec 2020 02:49:59 -0500 Subject: [PATCH] lib: remove unused code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/36632 Reviewed-By: Antoine du Hamel Reviewed-By: Michaƫl Zasso Reviewed-By: Ruben Bridgewater Reviewed-By: Rich Trott Reviewed-By: Yongsheng Zhang Reviewed-By: Benjamin Gruenbaum --- lib/internal/priority_queue.js | 12 ------------ test/parallel/test-priority-queue.js | 21 --------------------- 2 files changed, 33 deletions(-) diff --git a/lib/internal/priority_queue.js b/lib/internal/priority_queue.js index a0a18f7301e3b7..84db200b1cea96 100644 --- a/lib/internal/priority_queue.js +++ b/lib/internal/priority_queue.js @@ -2,7 +2,6 @@ const { Array, - ArrayPrototypeIndexOf, Symbol, } = primordials; @@ -105,17 +104,6 @@ module.exports = class PriorityQueue { } } - remove(value) { - const heap = this[kHeap]; - const pos = ArrayPrototypeIndexOf(heap, value); - if (pos < 1) - return false; - - this.removeAt(pos); - - return true; - } - shift() { const heap = this[kHeap]; const value = heap[1]; diff --git a/test/parallel/test-priority-queue.js b/test/parallel/test-priority-queue.js index f6318ede7ffbca..b98d228b08763b 100644 --- a/test/parallel/test-priority-queue.js +++ b/test/parallel/test-priority-queue.js @@ -43,27 +43,6 @@ const PriorityQueue = require('internal/priority_queue'); assert.strictEqual(queue.shift(), undefined); } -{ - // Checks that remove works as expected. - const queue = new PriorityQueue(); - for (let i = 16; i > 0; i--) - queue.insert(i); - - const removed = [5, 10, 15]; - for (const id of removed) - assert(queue.remove(id)); - - assert(!queue.remove(100)); - assert(!queue.remove(-100)); - - for (let i = 1; i < 17; i++) { - if (removed.indexOf(i) < 0) - assert.strictEqual(queue.shift(), i); - } - - assert.strictEqual(queue.shift(), undefined); -} - { // Make a max heap with a custom sort function. const queue = new PriorityQueue((a, b) => b - a);