Chromium Code Reviews| Index: Source/devtools/front_end/utilities.js |
| diff --git a/Source/devtools/front_end/utilities.js b/Source/devtools/front_end/utilities.js |
| index e6c3c3e215305efa972f8dd4268c3a4ea3b04d61..ae16a81140b19e48be8b3ff55c1fb8752972efe1 100644 |
| --- a/Source/devtools/front_end/utilities.js |
| +++ b/Source/devtools/front_end/utilities.js |
| @@ -717,29 +717,18 @@ function mergeOrIntersect(array1, array2, comparator, mergeNotIntersect) |
| var result = []; |
| var i = 0; |
| var j = 0; |
| - while (i < array1.length || j < array2.length) { |
| - if (i === array1.length) { |
| - result = result.concat(array2.slice(j)); |
| - j = array2.length; |
| - } else if (j === array2.length) { |
| - result = result.concat(array1.slice(i)); |
| - i = array1.length; |
| - } else { |
| - var compareValue = comparator(array1[i], array2[j]) |
| - if (compareValue < 0) { |
| - if (mergeNotIntersect) |
| - result.push(array1[i]); |
| - ++i; |
| - } else if (compareValue > 0) { |
| - if (mergeNotIntersect) |
| - result.push(array2[j]); |
| - ++j; |
| - } else { |
| - result.push(array1[i]); |
| - ++i; |
| - ++j; |
| - } |
| - } |
| + while (i < array1.length && j < array2.length) { |
| + var compareValue = comparator(array1[i], array2[j]); |
| + if (mergeNotIntersect || !compareValue) |
| + result.push(compareValue <= 0 ? array1[i] : array2[j]); |
| + if (compareValue <= 0) |
| + i++; |
| + if (compareValue >= 0) |
| + j++; |
| + } |
| + if (mergeNotIntersect) { |
| + while (i < array1.length) result.push(array1[i++]); |
|
caseq
2014/02/14 16:49:03
result.*$ => next line
alph
2014/02/14 16:51:20
It was nicer and I thought nobody notices. ;-)
|
| + while (j < array2.length) result.push(array2[j++]); |
|
caseq
2014/02/14 16:49:03
ditto
|
| } |
| return result; |
| } |