Bug 1596129 - Make use of std::transform, avoid doing an insert sort into an nsTArray in IDBDatabase::ObjectStoreNames. r=dom-workers-and-storage-reviewers,ttung
authorSimon Giesecke <sgiesecke@mozilla.com>
Thu, 21 Nov 2019 08:55:38 +0000
changeset 565106 08f48fdbec412e4e600cdacfe0bc1e93ab915664
parent 565105 577e972f6956a23496100e8b9afabcc8f713fdb6
child 565107 22e4a5fd9310712a749342bcc0e76570e7da9259
push id12351
push userffxbld-merge
push dateMon, 02 Dec 2019 11:32:26 +0000
treeherdermozilla-beta@dba4410526a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdom-workers-and-storage-reviewers, ttung
bugs1596129
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 1596129 - Make use of std::transform, avoid doing an insert sort into an nsTArray in IDBDatabase::ObjectStoreNames. r=dom-workers-and-storage-reviewers,ttung Depends on D52861 Differential Revision: https://phabricator.services.mozilla.com/D52862
dom/indexedDB/IDBDatabase.cpp
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -339,19 +339,21 @@ already_AddRefed<DOMStringList> IDBDatab
   const nsTArray<ObjectStoreSpec>& objectStores = mSpec->objectStores();
 
   RefPtr<DOMStringList> list = new DOMStringList();
 
   if (!objectStores.IsEmpty()) {
     nsTArray<nsString>& listNames = list->StringArray();
     listNames.SetCapacity(objectStores.Length());
 
-    for (uint32_t index = 0; index < objectStores.Length(); index++) {
-      listNames.InsertElementSorted(objectStores[index].metadata().name());
-    }
+    std::transform(
+        objectStores.cbegin(), objectStores.cend(), MakeBackInserter(listNames),
+        [](const auto& objectStore) { return objectStore.metadata().name(); });
+
+    listNames.Sort();
   }
 
   return list.forget();
 }
 
 already_AddRefed<Document> IDBDatabase::GetOwnerDocument() const {
   if (nsPIDOMWindowInner* window = GetOwner()) {
     nsCOMPtr<Document> doc = window->GetExtantDoc();