Bug 1186714 - bookmark backup yields the event loop occasionally to reduce jank. r=mak

This commit is contained in:
Mark Hammond 2015-08-26 10:43:07 +10:00
Родитель a48ff64fe9
Коммит 5de13ebb49
1 изменённых файлов: 9 добавлений и 0 удалений

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

@ -1921,6 +1921,7 @@ this.PlacesUtils = {
{ tags_folder: PlacesUtils.tagsFolderId,
charset_anno: PlacesUtils.CHARSET_ANNO,
item_guid: aItemGuid });
let yieldCounter = 0;
for (let row of rows) {
let item;
if (!rootItem) {
@ -1959,6 +1960,14 @@ this.PlacesUtils = {
if (item.type == this.TYPE_X_MOZ_PLACE_CONTAINER)
parentsMap.set(item.guid, item);
// With many bookmarks we end up stealing the CPU - even with yielding!
// So we let everyone else have a go every few items (bug 1186714).
if (++yieldCounter % 50 == 0) {
yield new Promise(resolve => {
Services.tm.currentThread.dispatch(resolve, Ci.nsIThread.DISPATCH_NORMAL);
});
}
}
return rootItem;