mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 12:49:35 +08:00
Merge pull request #3978 from stweil/sanfix
Modernize function ObjectCache::DeleteUnusedObjects (fix issue with s…
This commit is contained in:
commit
0680ba870e
@ -96,12 +96,16 @@ public:
|
||||
|
||||
void DeleteUnusedObjects() {
|
||||
std::lock_guard<std::mutex> guard(mu_);
|
||||
for (auto it = cache_.rbegin(); it != cache_.rend(); ++it) {
|
||||
if (it->count <= 0) {
|
||||
delete it->object;
|
||||
cache_.erase(std::next(it).base());
|
||||
}
|
||||
}
|
||||
cache_.erase(std::remove_if(cache_.begin(), cache_.end(),
|
||||
[](const ReferenceCount &it) {
|
||||
if (it.count <= 0) {
|
||||
delete it.object;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
cache_.end());
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user