mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 05:45:37 +00:00
Simplify Utils.merge to use Array.forEach and Array.push for bug 582023.
This commit is contained in:
parent
88ef92422f
commit
183c85bc14
@ -666,22 +666,9 @@ let Utils = {
|
||||
|
||||
// ----------
|
||||
// Function: merge
|
||||
// Merge two arrays and return the result.
|
||||
// Merge two array-like objects into the first and return it.
|
||||
merge: function(first, second) {
|
||||
var i = first.length, j = 0;
|
||||
|
||||
if (typeof second.length === "number") {
|
||||
for (let l = second.length; j < l; j++) {
|
||||
first[i++] = second[j];
|
||||
}
|
||||
} else {
|
||||
while (second[j] !== undefined) {
|
||||
first[i++] = second[j++];
|
||||
}
|
||||
}
|
||||
|
||||
first.length = i;
|
||||
|
||||
Array.forEach(second, function(el) Array.push(first, el));
|
||||
return first;
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user