2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-10-07 13:26:47 +00:00

Use vector instead of custom linked list.

This commit is contained in:
John Preston
2019-04-16 15:37:50 +04:00
parent 58d86af399
commit 2862070348
9 changed files with 129 additions and 268 deletions

View File

@@ -41,7 +41,7 @@ Row *IndexedList::addByName(Key key) {
return row;
}
Row *result = _list.addByName(key);
const auto result = _list.addByName(key);
for (const auto ch : key.entry()->chatListFirstLetters()) {
auto j = _index.find(ch);
if (j == _index.cend()) {
@@ -54,13 +54,13 @@ Row *IndexedList::addByName(Key key) {
return result;
}
void IndexedList::adjustByPos(const RowsByLetter &links) {
void IndexedList::adjustByDate(const RowsByLetter &links) {
for (const auto [ch, row] : links) {
if (ch == QChar(0)) {
_list.adjustByPos(row);
_list.adjustByDate(row);
} else {
if (auto it = _index.find(ch); it != _index.cend()) {
it->second->adjustByPos(row);
it->second->adjustByDate(row);
}
}
}
@@ -118,6 +118,8 @@ void IndexedList::peerNameChanged(
void IndexedList::adjustByName(
Key key,
const base::flat_set<QChar> &oldLetters) {
Expects(_sortMode == SortMode::Name);
const auto mainRow = _list.adjustByName(key);
if (!mainRow) return;