mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 20:59:36 +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() {
|
void DeleteUnusedObjects() {
|
||||||
std::lock_guard<std::mutex> guard(mu_);
|
std::lock_guard<std::mutex> guard(mu_);
|
||||||
for (auto it = cache_.rbegin(); it != cache_.rend(); ++it) {
|
cache_.erase(std::remove_if(cache_.begin(), cache_.end(),
|
||||||
if (it->count <= 0) {
|
[](const ReferenceCount &it) {
|
||||||
delete it->object;
|
if (it.count <= 0) {
|
||||||
cache_.erase(std::next(it).base());
|
delete it.object;
|
||||||
}
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
|
cache_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user