Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ekashida/983604 to your computer and use it in GitHub Desktop.
Save ekashida/983604 to your computer and use it in GitHub Desktop.
From 40254b255250d5b889699eb655c8d30c00d322a3 Mon Sep 17 00:00:00 2001
From: Tim Caswell <tim@creationix.com>
Date: Thu, 19 Aug 2010 18:58:28 -0700
Subject: [PATCH] Make process.nextTick worlds faster for large queues.
---
src/node.js | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/node.js b/src/node.js
index d38f12d..82a5937 100644
--- a/src/node.js
+++ b/src/node.js
@@ -47,9 +47,12 @@ process.evalcx = function () {
var nextTickQueue = [];
process._tickCallback = function () {
- for (var l = nextTickQueue.length; l; l--) {
- nextTickQueue.shift()();
+ var l = nextTickQueue.length;
+ if (l === 0) return;
+ for (var i = 0; i < l; i++) {
+ nextTickQueue[i]();
}
+ nextTickQueue.splice(0, l);
};
process.nextTick = function (callback) {
--
1.7.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment