2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

trying to optimize ClipReader

This commit is contained in:
John Preston
2016-01-01 15:42:06 +08:00
parent 30452289e5
commit ff481c810f
6 changed files with 159 additions and 87 deletions

View File

@@ -3594,6 +3594,7 @@ namespace Local {
struct ClearManagerData {
QThread *thread;
StorageMap images, stickers, audios;
WebFilesMap webFiles;
QMutex mutex;
QList<int> tasks;
bool working;
@@ -3693,6 +3694,22 @@ namespace Local {
_storageStickersSize = 0;
_mapChanged = true;
}
if (data->webFiles.isEmpty()) {
data->webFiles = _webFilesMap;
} else {
for (WebFilesMap::const_iterator i = _webFilesMap.cbegin(), e = _webFilesMap.cend(); i != e; ++i) {
QString k = i.key();
while (data->webFiles.constFind(k) != data->webFiles.cend()) {
k += '#';
}
data->webFiles.insert(k, i.value());
}
}
if (!_webFilesMap.isEmpty()) {
_webFilesMap.clear();
_storageWebFilesSize = 0;
_writeLocations();
}
if (data->audios.isEmpty()) {
data->audios = _audiosMap;
} else {
@@ -3745,6 +3762,7 @@ namespace Local {
int task = 0;
bool result = false;
StorageMap images, stickers, audios;
WebFilesMap webFiles;
{
QMutexLocker lock(&data->mutex);
if (data->tasks.isEmpty()) {
@@ -3755,6 +3773,7 @@ namespace Local {
images = data->images;
stickers = data->stickers;
audios = data->audios;
webFiles = data->webFiles;
}
switch (task) {
case ClearManagerAll: {
@@ -3786,6 +3805,9 @@ namespace Local {
for (StorageMap::const_iterator i = audios.cbegin(), e = audios.cend(); i != e; ++i) {
clearKey(i.value().first, UserPath);
}
for (WebFilesMap::const_iterator i = webFiles.cbegin(), e = webFiles.cend(); i != e; ++i) {
clearKey(i.value().first, UserPath);
}
result = true;
break;
}