From 13820bf27d2c4a4ff3f3a6400bed05b9e7bfe443 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Tue, 20 Aug 2019 18:10:35 -0500 Subject: [PATCH] Revert "IdList::RemoveTagged switch to std::remove_if from iteration. NFC." This reverts commit 0bb6a348e393f460c0b1bf6ab04b4bae41102688. --- src/dsc.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/dsc.h b/src/dsc.h index 15988e53..70483518 100644 --- a/src/dsc.h +++ b/src/dsc.h @@ -493,22 +493,24 @@ public: } void RemoveTagged() { - auto newEnd = std::remove_if(this->begin(), this->end(), [](T &t) { - if(t.tag) { - t.Clear(); - return true; - } - return false; - }); - if(newEnd != this->end()) { - while (newEnd != this->end()) { - newEnd->~T(); - ++newEnd; + int src, dest; + dest = 0; + for(src = 0; src < n; src++) { + if(elem[src].tag) { + // this item should be deleted + elem[src].Clear(); + } else { + if(src != dest) { + elem[dest] = elem[src]; + } + dest++; } } - n = newEnd - begin(); + for(int i = dest; i < n; i++) + elem[i].~T(); + n = dest; + // and elemsAllocated is untouched, because we didn't resize } - void RemoveById(H h) { ClearTags(); FindById(h)->tag = 1;