1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-14 23:12:28 +02:00

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);
};