MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / TrimBitmap

Method TrimBitmap

src/windows/AvatarCache.cpp:245–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245bool AvatarCache::TrimBitmap()
246{
247 int maxAge = 0;
248 std::string rid = "";
249
250 for (auto &b : m_profileToBitmap) {
251 if (maxAge < b.second.m_age &&
252 b.second.m_image != GetDefaultImage() &&
253 b.second.m_image != HIMAGE_ERROR &&
254 b.second.m_image != HIMAGE_LOADING) {
255 maxAge = b.second.m_age;
256 rid = b.first;
257 }
258 }
259
260 if (rid.empty()) return false;
261
262 auto iter = m_profileToBitmap.find(rid);
263 assert(iter != m_profileToBitmap.end());
264
265 auto iter2 = m_loadingResources.find(m_imagePlaces[iter->first].GetURL());
266
267 if (iter2 != m_loadingResources.end())
268 m_loadingResources.erase(iter2);
269
270 DbgPrintW("Deleting bitmap %s", rid.c_str());
271 DeleteImageIfNeeded(iter->second.m_image);
272 m_profileToBitmap.erase(iter);
273
274 return true;
275}
276
277int AvatarCache::TrimBitmaps(int count)
278{

Callers

nothing calls this directly

Calls 7

GetDefaultImageFunction · 0.85
DbgPrintWFunction · 0.85
GetURLMethod · 0.80
eraseMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected