mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
code review: avoid Array.splice/unshift
The array size stays the same, items are just moved around.
This commit is contained in:
parent
607968de7f
commit
4ab63e70fe
1 changed files with 5 additions and 2 deletions
|
|
@ -373,8 +373,11 @@
|
||||||
lookup: function(key) {
|
lookup: function(key) {
|
||||||
var value = this.map.get(key);
|
var value = this.map.get(key);
|
||||||
if ( value !== undefined && this.array[0] !== key ) {
|
if ( value !== undefined && this.array[0] !== key ) {
|
||||||
this.array.splice(this.array.indexOf(key), 1);
|
var i = this.array.indexOf(key);
|
||||||
this.array.unshift(key);
|
do {
|
||||||
|
this.array[i] = this.array[i-1];
|
||||||
|
} while ( --i );
|
||||||
|
this.array[0] = key;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue