mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-30 01:59:29 +00:00
Bug 1034490: Optimize saveStats function of NetworkStatsDB.
This commit is contained in:
parent
0628e78040
commit
c358f9f67f
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user