Bug 1455787 - Use an async iterator to build merge state params in the bookmarks mirror. r=tcsc
authorKit Cambridge <kit@yakshaving.ninja>
Fri, 20 Apr 2018 16:51:44 -0700
changeset 472166 c6a702c01ca6f56f21129b622f9dbbbbf6adf1e6
parent 472165 fc070a92030806614a5a532d5f0a040c0d351815
child 472167 5e8342edb62d87e2d8a3f2f20a13edc11526581d
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcsc
bugs1455787
milestone61.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 1455787 - Use an async iterator to build merge state params in the bookmarks mirror. r=tcsc MozReview-Commit-ID: DBurPu6vM2F
toolkit/components/places/SyncedBookmarksMirror.jsm
--- a/toolkit/components/places/SyncedBookmarksMirror.jsm
+++ b/toolkit/components/places/SyncedBookmarksMirror.jsm
@@ -1282,17 +1282,20 @@ class SyncedBookmarksMirror {
    * @param {Object[]} localDeletions
    *        `{ guid, level }` tuples for items to remove from Places and flag as
    *        merged.
    * @param {String[]} remoteDeletions
    *        Remotely deleted GUIDs that should be flagged as merged.
    */
   async updateLocalItemsInPlaces(mergedRoot, localDeletions, remoteDeletions) {
     MirrorLog.trace("Setting up merge states table");
-    let mergeStatesParams = Array.from(mergedRoot.mergeStatesParams());
+    let mergeStatesParams = [];
+    for await (let param of yieldingIterator(mergedRoot.mergeStatesParams())) {
+      mergeStatesParams.push(param);
+    }
     if (mergeStatesParams.length) {
       await this.db.execute(`
         INSERT INTO mergeStates(localGuid, mergedGuid, parentGuid, level,
                                 position, valueState, structureState)
         VALUES(IFNULL(:localGuid, :mergedGuid), :mergedGuid, :parentGuid,
                :level, :position, :valueState, :structureState)`,
         mergeStatesParams);
     }
@@ -1694,17 +1697,17 @@ class SyncedBookmarksMirror {
   async fetchLocalChangeRecords() {
     let changeRecords = {};
     let childRecordIdsByLocalParentId = new Map();
 
     let childGuidRows = await this.db.execute(`
       SELECT parentId, guid FROM structureToUpload
       ORDER BY parentId, position`);
 
-    for (let row of childGuidRows) {
+    for await (let row of yieldingIterator(childGuidRows)) {
       let localParentId = row.getResultByName("parentId");
       let childRecordId = PlacesSyncUtils.bookmarks.guidToRecordId(
         row.getResultByName("guid"));
       if (childRecordIdsByLocalParentId.has(localParentId)) {
         let childRecordIds = childRecordIdsByLocalParentId.get(localParentId);
         childRecordIds.push(childRecordId);
       } else {
         childRecordIdsByLocalParentId.set(localParentId, [childRecordId]);
@@ -3049,25 +3052,16 @@ class BookmarkNode {
   isFolder() {
     return this.kind == SyncedBookmarksMirror.KIND.FOLDER;
   }
 
   newerThan(otherNode) {
     return this.age < otherNode.age;
   }
 
-  * descendants() {
-    for (let node of this.children) {
-      yield node;
-      if (node.isFolder()) {
-        yield* node.descendants();
-      }
-    }
-  }
-
   /**
    * Checks if remoteNode has a kind that's compatible with this *local* node.
    * - Nodes with the same kind are always compatible.
    * - Local folders are compatible with remote livemarks, but not vice-versa
    *   (ie, remote folders are *not* compatible with local livemarks)
    * - Bookmarks and queries are always compatible.
    *
    * @return {Boolean}
@@ -3492,17 +3486,17 @@ class BookmarkMerger {
       if (!this.mentions(guid)) {
         this.deleteLocally.add(guid);
       }
     }
     return mergedRoot;
   }
 
   async subsumes(tree) {
-    for await (let guid of Async.yieldingIterator(tree.syncableGuids())) {
+    for await (let guid of yieldingIterator(tree.syncableGuids())) {
       if (!this.mentions(guid)) {
         return false;
       }
     }
     return true;
   }
 
   mentions(guid) {