persist local settings only when really needed

This commit is contained in:
gorhill 2015-03-04 19:38:19 -05:00
parent 5f65b1798a
commit a99bcd98fd
2 changed files with 8 additions and 1 deletions

View file

@ -713,9 +713,10 @@ PageStore.prototype.logRequest = function(context, result) {
if ( requestHostname === '' ) {
requestHostname = context.pageHostname;
}
var now = Date.now();
if ( this.hostnameToCountMap.hasOwnProperty(requestHostname) === false ) {
this.hostnameToCountMap[requestHostname] = 0;
this.contentLastModified = Date.now();
this.contentLastModified = now;
}
var c = result.charAt(1);
if ( c === '' || c === 'a' ) {
@ -727,6 +728,7 @@ PageStore.prototype.logRequest = function(context, result) {
this.perLoadBlockedRequestCount++;
µb.localSettings.blockedRequestCount++;
}
this.localSettingsModifyTime = now;
this.logBuffer.writeOne(context, result);
};

View file

@ -38,6 +38,11 @@
if ( typeof callback !== 'function' ) {
callback = this.noopFunc;
}
if ( this.localSettingsModifyTime <= this.localSettingsSaveTime ) {
callback();
return;
}
this.localSettingsSaveTime = Date.now();
vAPI.storage.set(this.localSettings, callback);
};