mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 660713 - Reuse arrays in Utils.arraySub and Utils.arrayUnion. r=philiKON
This commit is contained in:
parent
fa142c416c
commit
06482c5bf2
@ -1163,16 +1163,23 @@ let Utils = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Create an array like the first but without elements of the second
|
||||
* Create an array like the first but without elements of the second. Reuse
|
||||
* arrays if possible.
|
||||
*/
|
||||
arraySub: function arraySub(minuend, subtrahend) {
|
||||
if (!minuend.length || !subtrahend.length)
|
||||
return minuend;
|
||||
return minuend.filter(function(i) subtrahend.indexOf(i) == -1);
|
||||
},
|
||||
|
||||
/**
|
||||
* Build the union of two arrays.
|
||||
* Build the union of two arrays. Reuse arrays if possible.
|
||||
*/
|
||||
arrayUnion: function arrayUnion(foo, bar) {
|
||||
if (!foo.length)
|
||||
return bar;
|
||||
if (!bar.length)
|
||||
return foo;
|
||||
return foo.concat(Utils.arraySub(bar, foo));
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user