Bug 1598164 - Make use of std::copy_if/MakeBackInserter in IDBTransaction::AbortInternal. r=dom-workers-and-storage-reviewers,ytausky
authorSimon Giesecke <sgiesecke@mozilla.com>
Wed, 27 Nov 2019 10:54:57 +0000
changeset 503995 812780d706aeb4af9807d8da8662fdcf8b2ea721
parent 503994 82141e34c89fecaed2c0700bfc11d5b5401645a3
child 503996 6b74a831286a92f89fba8f685efa7e46bb11a0cd
push id36854
push useraciure@mozilla.com
push dateWed, 27 Nov 2019 16:05:28 +0000
treeherdermozilla-central@472828bc516f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdom-workers-and-storage-reviewers, ytausky
bugs1598164
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/indexedDB/IDBTransaction.cpp
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -637,35 +637,24 @@ void IDBTransaction::AbortInternal(const
       mObjectStores.RemoveElementsAt(
           std::remove_if(mObjectStores.begin(), mObjectStores.end(),
                          [&validIds](const auto& objectStore) {
                            return !validIds.Contains(
                                uint64_t(objectStore->Id()));
                          }),
           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();
   }
 
   // Fire the abort event if there are no outstanding requests. Otherwise the
   // abort event will be fired when all outstanding requests finish.
   if (needToSendAbort) {
     SendAbort(aAbortCode);