mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 09:31:01 +01:00
persist local settings only when really needed
This commit is contained in:
parent
5f65b1798a
commit
a99bcd98fd
2 changed files with 8 additions and 1 deletions
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue