Browse Source

process: optimize process.nextTick()

33% performance boost on large nextTick queues.
v0.7.4-release
Ben Noordhuis 13 years ago
parent
commit
4d4900fc65
  1. 12
      src/node.js

12
src/node.js

@ -185,20 +185,18 @@
var l = nextTickQueue.length; var l = nextTickQueue.length;
if (l === 0) return; if (l === 0) return;
var q = nextTickQueue;
nextTickQueue = [];
try { try {
for (var i = 0; i < l; i++) { for (var i = 0; i < l; i++) q[i]();
nextTickQueue[i]();
}
} }
catch (e) { catch (e) {
nextTickQueue.splice(0, i + 1); if (nextTickQueue.length) {
if (i + 1 < l) {
process._needTickCallback(); process._needTickCallback();
} }
throw e; // process.nextTick error, or 'error' event on first tick throw e; // process.nextTick error, or 'error' event on first tick
} }
nextTickQueue.splice(0, l);
}; };
process.nextTick = function(callback) { process.nextTick = function(callback) {

Loading…
Cancel
Save