Skip to content

Commit

Permalink
fixup: rm unnecessary conditional checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Sep 26, 2015
1 parent 9f28c3c commit d07e3a7
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,23 @@ var triggerTimers = new Map();
// the main function - creates lists on demand and the watchers associated
// with them.
function insert(item, msecs) {
item._idleStart = Timer.now();
item._idleTimeout = msecs;

if (msecs < 0) return;

var timer;

if (! lists[msecs]) {
timer = new Timer();
timer.start(msecs, 0);
timer.msecs = msecs;
timer[kOnTimeout] = listOnTimeout;
item._idleStart = Timer.now();
item._idleTimeout = msecs;

lists[msecs] = new Set();
triggerTimers.set(msecs, timer);
if (lists[msecs]) {
lists[msecs].add(item);
return;
}

lists[msecs].add(item);
lists[msecs] = new Set().add(item);

const timer = new Timer();
timer.start(msecs, 0);
timer.msecs = msecs;
timer[kOnTimeout] = listOnTimeout;
triggerTimers.set(msecs, timer);
}

function listOnTimeout() {
Expand All @@ -51,53 +50,54 @@ function listOnTimeout() {
var now = Timer.now();

var diff, first, threw;
if (lists[msecs]) {
for (let first of lists[msecs]) {
diff = now - first._idleStart;
if (diff < msecs) {
list.start(msecs - diff, 0);
return;
} else {
lists[msecs].delete(first);
if (!first._onTimeout) continue;

// v0.4 compatibility: if the timer callback throws and the
// domain or uncaughtException handler ignore the exception,
// other timers that expire on this tick should still run.
//
// https://github.com/joyent/node/issues/2631
var domain = first.domain;
if (domain && domain._disposed)
continue;

try {
if (domain)
domain.enter();
threw = true;
first._called = true;
first._onTimeout();
if (domain)
domain.exit();
threw = false;
} finally {
if (threw) {
// We need to continue processing after domain error handling
// is complete, but not by using whatever domain was left over
// when the timeout threw its exception.
var oldDomain = process.domain;
process.domain = null;
process.nextTick(listOnTimeoutNT, list);
process.domain = oldDomain;
}
for (let first of lists[msecs]) {
diff = now - first._idleStart;
if (diff < msecs) {
list.start(msecs - diff, 0);
return;
} else {
lists[msecs].delete(first);
if (!first._onTimeout) continue;

// v0.4 compatibility: if the timer callback throws and the
// domain or uncaughtException handler ignore the exception,
// other timers that expire on this tick should still run.
//
// https://github.com/joyent/node/issues/2631
var domain = first.domain;
if (domain && domain._disposed)
continue;

try {
if (domain)
domain.enter();

threw = true;
first._called = true;
first._onTimeout();

if (domain)
domain.exit();

threw = false;
} finally {
if (threw) {
// We need to continue processing after domain error handling
// is complete, but not by using whatever domain was left over
// when the timeout threw its exception.
var oldDomain = process.domain;
process.domain = null;
process.nextTick(listOnTimeoutNT, list);
process.domain = oldDomain;
}
}
}
}

list.close();
if (lists[msecs] && lists[msecs].size === 0) {
delete lists[msecs];
}

list.close();
}


Expand Down Expand Up @@ -530,7 +530,7 @@ function unrefTimeout() {
// call the onTimeout callback for those expired,
// and rearm the actual timer if the next timeout to expire
// will expire before the current actual timer.
for (var cur of unrefList) {
for (let cur of unrefList) {
timeSinceLastActive = now - cur._idleStart;

if (timeSinceLastActive < cur._idleTimeout) {
Expand Down

0 comments on commit d07e3a7

Please sign in to comment.