Skip to content

Commit 157ced8

Browse files
committed
fixup! fixup! timers: use timerListMap and outstandingQueue to count timers
Signed-off-by: Darshan Sen <[email protected]>
1 parent f973ffe commit 157ced8

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

lib/internal/bootstrap/node.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const {
4242
Array,
4343
ArrayPrototypeConcat,
4444
ArrayPrototypeFill,
45-
ArrayPrototypeForEach,
4645
FunctionPrototypeCall,
4746
JSONParse,
4847
ObjectDefineProperty,
@@ -157,22 +156,21 @@ const rawMethods = internalBinding('process_methods');
157156
process._getActiveHandles = rawMethods._getActiveHandles;
158157

159158
process.getActiveResourcesInfo = function() {
160-
var timeoutCount = 0;
161-
ArrayPrototypeForEach(ObjectValues(internalTimers.timerListMap),
162-
(list) => {
163-
var timer = list._idlePrev === list ?
164-
null : list._idlePrev;
165-
while (timer !== null) {
166-
timeoutCount += timer.hasRef();
167-
timer = timer._idlePrev === list ?
168-
null : timer._idlePrev;
169-
}
170-
});
171-
172-
var immediateCount = 0;
159+
let timeoutCount = 0;
160+
const lists = ObjectValues(internalTimers.timerListMap);
161+
for (let i = 0; i < lists.length; ++i) {
162+
const list = lists[i];
163+
let timer = list._idlePrev;
164+
while (timer !== list) {
165+
timeoutCount += timer.hasRef();
166+
timer = timer._idlePrev;
167+
}
168+
}
169+
170+
let immediateCount = 0;
173171
const queue = internalTimers.outstandingQueue.head !== null ?
174172
internalTimers.outstandingQueue : internalTimers.immediateQueue;
175-
var immediate = queue.head;
173+
let immediate = queue.head;
176174
while (immediate !== null) {
177175
immediateCount += immediate.hasRef();
178176
immediate = immediate._idleNext;

0 commit comments

Comments
 (0)