mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02: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
@ -373,8 +373,11 @@
|
||||
lookup: function(key) {
|
||||
var value = this.map.get(key);
|
||||
if ( value !== undefined && this.array[0] !== key ) {
|
||||
this.array.splice(this.array.indexOf(key), 1);
|
||||
this.array.unshift(key);
|
||||
var i = this.array.indexOf(key);
|
||||
do {
|
||||
this.array[i] = this.array[i-1];
|
||||
} while ( --i );
|
||||
this.array[0] = key;
|
||||
}
|
||||
return value;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user