Bug 1598164 - Make use of std::copy_if/MakeBackInserter in IDBTransaction::AbortInternal. r=dom-workers-and-storage-reviewers,ytausky

Depends on D54322

Differential Revision: https://phabricator.services.mozilla.com/D54732

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2019-11-27 10:54:57 +00:00
Родитель 55a2f652bc
Коммит 9e2165d850
1 изменённых файлов: 8 добавлений и 19 удалений

Просмотреть файл

@ -642,25 +642,14 @@ void IDBTransaction::AbortInternal(const nsresult aAbortCode,
}),
mObjectStores.end());
// TODO: if nsTArray had an insert iterator, we could use the following
// instead:
// std::copy_if(std::make_move_iterator(mDeletedObjectStores.begin()),
// std::make_move_iterator(mDeletedObjectStores.end()),
// std::back_inserter(mObjectStores),
// [&validIds](const auto& deletedObjectStore) {
// const int64_t objectStoreId = deletedObjectStore->Id();
// MOZ_ASSERT(objectStoreId);
// return validIds.Contains(uint64_t(objectStoreId));
// });
for (auto& deletedObjectStore : mDeletedObjectStores) {
const int64_t objectStoreId = deletedObjectStore->Id();
MOZ_ASSERT(objectStoreId);
if (validIds.Contains(uint64_t(objectStoreId))) {
RefPtr<IDBObjectStore>* objectStore = mObjectStores.AppendElement();
objectStore->swap(deletedObjectStore);
}
}
std::copy_if(std::make_move_iterator(mDeletedObjectStores.begin()),
std::make_move_iterator(mDeletedObjectStores.end()),
MakeBackInserter(mObjectStores),
[&validIds](const auto& deletedObjectStore) {
const int64_t objectStoreId = deletedObjectStore->Id();
MOZ_ASSERT(objectStoreId);
return validIds.Contains(uint64_t(objectStoreId));
});
}
mDeletedObjectStores.Clear();
}