timers: cleanup interval handling
Uses `null` as the false-y value for `_repeat` as like other properties. Removes un-reachable statement in setInterval’s `wrapper()`. PR-URL: https://github.com/iojs/io.js/pull/1272 Reviewed-by: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
caf0b36de3
commit
776b73b243
@ -272,8 +272,6 @@ exports.setInterval = function(callback, repeat) {
|
|||||||
|
|
||||||
function wrapper() {
|
function wrapper() {
|
||||||
timer._repeat.call(this);
|
timer._repeat.call(this);
|
||||||
// If callback called clearInterval().
|
|
||||||
if (timer._repeat === null) return;
|
|
||||||
// If timer is unref'd (or was - it's permanently removed from the list.)
|
// If timer is unref'd (or was - it's permanently removed from the list.)
|
||||||
if (this._handle) {
|
if (this._handle) {
|
||||||
this._handle.start(repeat, 0);
|
this._handle.start(repeat, 0);
|
||||||
@ -287,7 +285,7 @@ exports.setInterval = function(callback, repeat) {
|
|||||||
|
|
||||||
exports.clearInterval = function(timer) {
|
exports.clearInterval = function(timer) {
|
||||||
if (timer && timer._repeat) {
|
if (timer && timer._repeat) {
|
||||||
timer._repeat = false;
|
timer._repeat = null;
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -300,7 +298,7 @@ const Timeout = function(after) {
|
|||||||
this._idleNext = this;
|
this._idleNext = this;
|
||||||
this._idleStart = null;
|
this._idleStart = null;
|
||||||
this._onTimeout = null;
|
this._onTimeout = null;
|
||||||
this._repeat = false;
|
this._repeat = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
Timeout.prototype.unref = function() {
|
Timeout.prototype.unref = function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user