mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 09:31:01 +01:00
code review: chromium 45 supports arrow functions = start using them
This commit is contained in:
parent
2da91b8aef
commit
2c843f6e69
1 changed files with 7 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
|||
/*******************************************************************************
|
||||
|
||||
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
|
||||
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.
|
||||
// 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 = {
|
||||
strings: new Map(),
|
||||
timer: undefined,
|
||||
last: 0,
|
||||
|
||||
lookup: function(s) {
|
||||
var t = this.strings.get(s);
|
||||
let t = this.strings.get(s);
|
||||
if ( t === undefined ) {
|
||||
this.strings.set(s, s);
|
||||
t = this.strings.get(s);
|
||||
if ( this.timer === undefined ) { this.cleanupAsync(); }
|
||||
t = this.strings.set(s, s).get(s);
|
||||
if ( this.timer === undefined ) {
|
||||
this.timer = vAPI.setTimeout(() => { this.cleanup(); }, 10000);
|
||||
}
|
||||
}
|
||||
this.last = Date.now();
|
||||
return t;
|
||||
},
|
||||
|
||||
cleanupAsync: function() {
|
||||
this.timer = vAPI.setTimeout(this.cleanup.bind(this), 10000);
|
||||
},
|
||||
|
||||
cleanup: function() {
|
||||
if ( (Date.now() - this.last) < 10000 ) {
|
||||
this.timer = vAPI.setTimeout(this.cleanup.bind(this), 10000);
|
||||
this.timer = vAPI.setTimeout(() => { this.cleanup(); }, 10000);
|
||||
} else {
|
||||
this.timer = undefined;
|
||||
this.strings.clear();
|
||||
|
|
Loading…
Reference in a new issue