Performance improvement of random.pop()
This does not do the same array type checks as random.item(), but these should be standardized throughout the module.
This commit is contained in:
parent
8e084eb878
commit
227f6a1958
1 changed files with 3 additions and 2 deletions
|
@ -146,8 +146,9 @@ var random = {
|
|||
// Removes and returns a random item from an array
|
||||
let i, obj;
|
||||
|
||||
obj = this.item(arr);
|
||||
arr.splice(arr.indexOf(obj), 1);
|
||||
i = this.number(arr.length);
|
||||
obj = arr[i];
|
||||
arr.splice(i, 1);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue