去空格,优化addArray,removeArray性能
This commit is contained in:
parent
e0f9e919c7
commit
27ddea0730
11
game/game.js
11
game/game.js
|
@ -8487,7 +8487,8 @@
|
|||
enumerable:false,
|
||||
writable:true,
|
||||
value:function(){
|
||||
return Array.prototype.add.apply(this,Array.from(arguments).flat());
|
||||
for(const i of arguments) this.add(...i);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(Array.prototype,"remove",{
|
||||
|
@ -8508,7 +8509,7 @@
|
|||
enumerable:false,
|
||||
writable:true,
|
||||
value:function(){
|
||||
return Array.prototype.remove.apply(this,Array.from(arguments).flat());
|
||||
for(const i of arguments) this.add(...i);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(Array.prototype,"unique",{
|
||||
|
@ -8516,7 +8517,7 @@
|
|||
enumerable:false,
|
||||
writable:true,
|
||||
value:function(){
|
||||
let uniqueArray = this.toUniqued();
|
||||
let uniqueArray=[...new Set(this)];
|
||||
this.length=uniqueArray.length;
|
||||
for(let i=0;i<uniqueArray.length;i++) this[i]=uniqueArray[i];
|
||||
return this;
|
||||
|
@ -8575,11 +8576,11 @@
|
|||
enumerable:false,
|
||||
writable:true,
|
||||
value:function(){
|
||||
var list = [];
|
||||
let list=[];
|
||||
while(this.length){
|
||||
list.push(this.randomRemove());
|
||||
}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
for(let i=0;i<list.length;i++){
|
||||
this.push(list[i]);
|
||||
}
|
||||
return this;
|
||||
|
|
Loading…
Reference in New Issue