File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -97,12 +97,11 @@ module.exports = class PriorityQueue {
9797 }
9898
9999 removeAt ( pos ) {
100- if ( pos > this . #size) return ;
101-
102100 const heap = this . #heap;
103- const size = -- this . #size;
104- heap [ pos ] = heap [ size + 1 ] ;
105- heap [ size + 1 ] = undefined ;
101+ let size = this . #size;
102+ heap [ pos ] = heap [ size ] ;
103+ heap [ size ] = undefined ;
104+ size = -- this . #size;
106105
107106 if ( size > 0 && pos <= size ) {
108107 if ( pos > 1 && this . #compare( heap [ pos >> 1 ] , heap [ pos ] ) > 0 )
Original file line number Diff line number Diff line change @@ -102,9 +102,6 @@ const PriorityQueue = require('internal/priority_queue');
102102 // Check that removing the last item doesn't throw
103103 queue . removeAt ( 6 ) ;
104104
105- // Check that removing an item that doesn't exist doesn't throw
106- queue . removeAt ( 15 ) ;
107-
108105 assert . strictEqual ( queue . shift ( ) . value , 1 ) ;
109106 assert . strictEqual ( queue . shift ( ) . value , 2 ) ;
110107 assert . strictEqual ( queue . shift ( ) . value , 2 ) ;
You can’t perform that action at this time.
0 commit comments