code review: chromium 45 supports arrow functions = start using them

This commit is contained in:
Raymond Hill 2018-06-01 11:49:48 -04:00
parent 2da91b8aef
commit 2c843f6e69
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 7 additions and 13 deletions

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
uBlock Origin - a browser extension to block requests. uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2017 Raymond Hill Copyright (C) 2014-2018 Raymond Hill
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -322,32 +322,26 @@
// longer needed. A timer will be used for self-garbage-collect. // longer needed. A timer will be used for self-garbage-collect.
// Cleaning up 10s after last hit sounds reasonable. // Cleaning up 10s after last hit sounds reasonable.
// https://github.com/gorhill/uBlock/issues/2656
// Can't use chained calls if we want to support legacy Map().
µBlock.stringDeduplicater = { µBlock.stringDeduplicater = {
strings: new Map(), strings: new Map(),
timer: undefined, timer: undefined,
last: 0, last: 0,
lookup: function(s) { lookup: function(s) {
var t = this.strings.get(s); let t = this.strings.get(s);
if ( t === undefined ) { if ( t === undefined ) {
this.strings.set(s, s); t = this.strings.set(s, s).get(s);
t = this.strings.get(s); if ( this.timer === undefined ) {
if ( this.timer === undefined ) { this.cleanupAsync(); } this.timer = vAPI.setTimeout(() => { this.cleanup(); }, 10000);
}
} }
this.last = Date.now(); this.last = Date.now();
return t; return t;
}, },
cleanupAsync: function() {
this.timer = vAPI.setTimeout(this.cleanup.bind(this), 10000);
},
cleanup: function() { cleanup: function() {
if ( (Date.now() - this.last) < 10000 ) { if ( (Date.now() - this.last) < 10000 ) {
this.timer = vAPI.setTimeout(this.cleanup.bind(this), 10000); this.timer = vAPI.setTimeout(() => { this.cleanup(); }, 10000);
} else { } else {
this.timer = undefined; this.timer = undefined;
this.strings.clear(); this.strings.clear();