diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-04-03 22:05:49 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-06-24 14:17:58 +0200 |
commit | 9bbacc70ab3af6bd652a4c6ff5bea1f7ea307eee (patch) | |
tree | fd5efab061e7385437214dab88dfbbe641ac87b8 /common/rfb/DecodeManager.cxx | |
parent | 9a8eb803bcf9b6e4443aa3e15a4600b177a1e725 (diff) | |
download | tigervnc-9bbacc70ab3af6bd652a4c6ff5bea1f7ea307eee.tar.gz tigervnc-9bbacc70ab3af6bd652a4c6ff5bea1f7ea307eee.zip |
Simplify code using range-based for loops
These are often more readable as they avoid a lot of the boilerplate of
iterating over fixed arrays or STL containers.
Note that this change is very conservative to avoid noise in "git
blame". Only loops where this is a clear improvement have been
converted.
Diffstat (limited to 'common/rfb/DecodeManager.cxx')
-rw-r--r-- | common/rfb/DecodeManager.cxx | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/common/rfb/DecodeManager.cxx b/common/rfb/DecodeManager.cxx index 1e71b8b9..63ab987d 100644 --- a/common/rfb/DecodeManager.cxx +++ b/common/rfb/DecodeManager.cxx @@ -97,8 +97,8 @@ DecodeManager::~DecodeManager() delete producerCond; delete queueMutex; - for (size_t i = 0; i < sizeof(decoders)/sizeof(decoders[0]); i++) - delete decoders[i]; + for (Decoder* decoder : decoders) + delete decoder; } bool DecodeManager::decodeRect(const Rect& r, int encoding, @@ -347,7 +347,6 @@ void DecodeManager::DecodeThread::worker() DecodeManager::QueueEntry* DecodeManager::DecodeThread::findEntry() { - std::list<DecodeManager::QueueEntry*>::iterator iter; Region lockedRegion; if (manager->workQueue.empty()) @@ -356,15 +355,7 @@ DecodeManager::QueueEntry* DecodeManager::DecodeThread::findEntry() if (!manager->workQueue.front()->active) return manager->workQueue.front(); - for (iter = manager->workQueue.begin(); - iter != manager->workQueue.end(); - ++iter) { - DecodeManager::QueueEntry* entry; - - std::list<DecodeManager::QueueEntry*>::iterator iter2; - - entry = *iter; - + for (DecodeManager::QueueEntry* entry : manager->workQueue) { // Another thread working on this? if (entry->active) goto next; @@ -372,8 +363,10 @@ DecodeManager::QueueEntry* DecodeManager::DecodeThread::findEntry() // If this is an ordered decoder then make sure this is the first // rectangle in the queue for that decoder if (entry->decoder->flags & DecoderOrdered) { - for (iter2 = manager->workQueue.begin(); iter2 != iter; ++iter2) { - if (entry->encoding == (*iter2)->encoding) + for (DecodeManager::QueueEntry* entry2 : manager->workQueue) { + if (entry2 == entry) + break; + if (entry->encoding == entry2->encoding) goto next; } } @@ -381,15 +374,17 @@ DecodeManager::QueueEntry* DecodeManager::DecodeThread::findEntry() // For a partially ordered decoder we must ask the decoder for each // pair of rectangles. if (entry->decoder->flags & DecoderPartiallyOrdered) { - for (iter2 = manager->workQueue.begin(); iter2 != iter; ++iter2) { - if (entry->encoding != (*iter2)->encoding) + for (DecodeManager::QueueEntry* entry2 : manager->workQueue) { + if (entry2 == entry) + break; + if (entry->encoding != entry2->encoding) continue; if (entry->decoder->doRectsConflict(entry->rect, entry->bufferStream->data(), entry->bufferStream->length(), - (*iter2)->rect, - (*iter2)->bufferStream->data(), - (*iter2)->bufferStream->length(), + entry2->rect, + entry2->bufferStream->data(), + entry2->bufferStream->length(), *entry->server)) goto next; } |