diff options
author | Doron Pagot <doronpagot@gmail.com> | 2017-07-21 15:26:05 +0300 |
---|---|---|
committer | Doron Pagot <doronpagot@gmail.com> | 2017-07-21 15:26:05 +0300 |
commit | 6b63c2eda5be34fa157431d5e3bfae721f1bdb4d (patch) | |
tree | 718be63de80f31eefabc6780c5cfb37db90b8a5a /lib/internal/queue.js | |
parent | 0040c54061bb6f4a083dd7d13ca28265644268ff (diff) | |
download | async-6b63c2eda5be34fa157431d5e3bfae721f1bdb4d.tar.gz |
Use shift instead of splice (when possible) in queue
Diffstat (limited to 'lib/internal/queue.js')
-rw-r--r-- | lib/internal/queue.js | 4 |
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); } |