summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoron Pagot <doronpagot@gmail.com>2017-07-21 15:26:05 +0300
committerDoron Pagot <doronpagot@gmail.com>2017-07-21 15:26:05 +0300
commit6b63c2eda5be34fa157431d5e3bfae721f1bdb4d (patch)
tree718be63de80f31eefabc6780c5cfb37db90b8a5a
parent0040c54061bb6f4a083dd7d13ca28265644268ff (diff)
downloadasync-6b63c2eda5be34fa157431d5e3bfae721f1bdb4d.tar.gz
Use shift instead of splice (when possible) in queue
-rw-r--r--lib/internal/queue.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/internal/queue.js b/lib/internal/queue.js
index 4f57edb..1a3f4cb 100644
--- a/lib/internal/queue.js
+++ b/lib/internal/queue.js
@@ -65,7 +65,9 @@ export default function queue(worker, concurrency, payload) {
var task = tasks[i];
var index = indexOf(workersList, task, 0);
- if (index >= 0) {
+ if (index === 0) {
+ workersList.shift();
+ } else if (index > 0) {
workersList.splice(index, 1);
}