diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2023-03-21 13:04:21 +0000 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2023-03-21 13:04:21 +0000 |
commit | d8427cc28e3a9ac3319fb452b16661957c812b8f (patch) | |
tree | b49c4726fe7cae0caf42c070e0a109d6365fe20e /src/checkqueue.h | |
parent | 9a0b5241396efe3b3ceb3931717c30bb94f99bfb (diff) |
refactor: Use move semantics in `CCheckQueue::Loop`
Co-authored-by: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
Diffstat (limited to 'src/checkqueue.h')
-rw-r--r-- | src/checkqueue.h | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/checkqueue.h b/src/checkqueue.h index a4818ad44f..2c21e5f7d0 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -112,13 +112,9 @@ private: // * Try to account for idle jobs which will instantly start helping. // * Don't do batches smaller than 1 (duh), or larger than nBatchSize. nNow = std::max(1U, std::min(nBatchSize, (unsigned int)queue.size() / (nTotal + nIdle + 1))); - vChecks.resize(nNow); - for (unsigned int i = 0; i < nNow; i++) { - // We want the lock on the m_mutex to be as short as possible, so swap jobs from the global - // queue to the local batch vector instead of copying. - vChecks[i].swap(queue.back()); - queue.pop_back(); - } + auto start_it = queue.end() - nNow; + vChecks.assign(std::make_move_iterator(start_it), std::make_move_iterator(queue.end())); + queue.erase(start_it, queue.end()); // Check whether we need to do work at all fOk = fAllOk; } |