From 48851bffc97b031cb8f5a381123945a2dc3bb098 Mon Sep 17 00:00:00 2001 From: SlaneYang Date: Wed, 7 Nov 2018 11:55:12 +0800 Subject: [PATCH 1/2] perf(queue): Use shift instead of splice (when possible) in queue --- lib/async.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/async.js b/lib/async.js index cfb3691c..976dbf3d 100644 --- a/lib/async.js +++ b/lib/async.js @@ -8065,7 +8065,11 @@ task = tasks[taskIndex]; while (++index < size) { if (workersList[index] === task) { - workersList.splice(index, 1); + if (index === 0) { + workersList.shift(); + } else if (index > 0) { + workersList.splice(index, 1); + } index = size; size--; } From 5f69b4d2e114bb3ffa0a665ce5c474dc0953ad81 Mon Sep 17 00:00:00 2001 From: SlaneYang Date: Wed, 7 Nov 2018 15:09:33 +0800 Subject: [PATCH 2/2] perf(queue): Use shift instead of splice (when possible) in queue --- lib/async.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/async.js b/lib/async.js index 976dbf3d..59384335 100644 --- a/lib/async.js +++ b/lib/async.js @@ -8067,7 +8067,7 @@ if (workersList[index] === task) { if (index === 0) { workersList.shift(); - } else if (index > 0) { + } else { workersList.splice(index, 1); } index = size;