timers: fix performance regression
Fix a 5-7% performance regression in the http_simple benchmark that was introduced by the following commits: 348d8cd timers: remove _idleTimeout from item in .unenroll() f2f3028 timers: fix memory leak in setTimeout 098fef6 timers: remember extra setTimeout() arguments when timeout==0 Fix suggested by Bert Belder.
This commit is contained in:
parent
892ba87866
commit
d8c178bc16
@ -108,8 +108,8 @@ var unenroll = exports.unenroll = function(item) {
|
|||||||
list.close();
|
list.close();
|
||||||
delete lists[item._idleTimeout];
|
delete lists[item._idleTimeout];
|
||||||
}
|
}
|
||||||
//if active is called later, then we want to make sure not to insert again
|
// if active is called later, then we want to make sure not to insert again
|
||||||
delete item._idleTimeout;
|
item._idleTimeout = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -151,17 +151,18 @@ exports.setTimeout = function(callback, after) {
|
|||||||
if (after <= 0) {
|
if (after <= 0) {
|
||||||
// Use the slow case for after == 0
|
// Use the slow case for after == 0
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
|
timer._callback = callback;
|
||||||
|
|
||||||
if (arguments.length <= 2) {
|
if (arguments.length <= 2) {
|
||||||
timer._onTimeout = function() {
|
timer._onTimeout = function() {
|
||||||
callback();
|
this._callback();
|
||||||
timer.close();
|
this.close();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var args = Array.prototype.slice.call(arguments, 2);
|
var args = Array.prototype.slice.call(arguments, 2);
|
||||||
timer._onTimeout = function() {
|
timer._onTimeout = function() {
|
||||||
callback.apply(timer, args);
|
this._callback.apply(timer, args);
|
||||||
timer.close();
|
this.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user