Bug 1034490: Optimize saveStats function of NetworkStatsDB.

This commit is contained in:
Albert Crespell 2014-07-11 07:02:59 +02:00
parent 0628e78040
commit c358f9f67f

View File

@ -382,7 +382,11 @@ NetworkStatsDB.prototype = {
debug("New stats: " + JSON.stringify(stats));
}
let request = aStore.index("network").openCursor(stats.network, "prev");
let lowerFilter = [stats.appId, stats.serviceType, stats.network, 0];
let upperFilter = [stats.appId, stats.serviceType, stats.network, ""];
let range = IDBKeyRange.bound(lowerFilter, upperFilter, false, false);
let request = aStore.openCursor(range, 'prev');
request.onsuccess = function onsuccess(event) {
let cursor = event.target.result;
if (!cursor) {
@ -401,16 +405,9 @@ NetworkStatsDB.prototype = {
return;
}
let value = cursor.value;
if (stats.appId != value.appId ||
(stats.appId == 0 && stats.serviceType != value.serviceType)) {
cursor.continue();
return;
}
// There are old samples
if (DEBUG) {
debug("Last value " + JSON.stringify(value));
debug("Last value " + JSON.stringify(cursor.value));
}
// Remove stats previous to now - VALUE_MAX_LENGTH