| Index: src/array.js
|
| diff --git a/src/array.js b/src/array.js
|
| index 3d4a066bc5e0c244a3e0187d267e3e67e8515a01..44deff7de42c60986741615b1be389f9668dbf85 100644
|
| --- a/src/array.js
|
| +++ b/src/array.js
|
| @@ -863,11 +863,12 @@ function ArraySort(comparefn) {
|
| var t_array = [];
|
| // Use both 'from' and 'to' to determine the pivot candidates.
|
| var increment = 200 + ((to - from) & 15);
|
| - for (var i = from + 1; i < to - 1; i += increment) {
|
| - t_array.push([i, a[i]]);
|
| + for (var i = from + 1, j = 0; i < to - 1; i += increment, j++) {
|
| + t_array[j] = [i, a[i]];
|
| }
|
| - t_array.sort(function(a, b) {
|
| - return %_CallFunction(receiver, a[1], b[1], comparefn) } );
|
| + %_CallFunction(t_array, function(a, b) {
|
| + return %_CallFunction(receiver, a[1], b[1], comparefn);
|
| + }, ArraySort);
|
| var third_index = t_array[t_array.length >> 1][0];
|
| return third_index;
|
| }
|
| @@ -969,7 +970,7 @@ function ArraySort(comparefn) {
|
| // It's an interval.
|
| var proto_length = indices;
|
| for (var i = 0; i < proto_length; i++) {
|
| - if (!obj.hasOwnProperty(i) && proto.hasOwnProperty(i)) {
|
| + if (!HAS_OWN_PROPERTY(obj, i) && HAS_OWN_PROPERTY(proto, i)) {
|
| obj[i] = proto[i];
|
| if (i >= max) { max = i + 1; }
|
| }
|
| @@ -977,8 +978,8 @@ function ArraySort(comparefn) {
|
| } else {
|
| for (var i = 0; i < indices.length; i++) {
|
| var index = indices[i];
|
| - if (!IS_UNDEFINED(index) &&
|
| - !obj.hasOwnProperty(index) && proto.hasOwnProperty(index)) {
|
| + if (!IS_UNDEFINED(index) && !HAS_OWN_PROPERTY(obj, index)
|
| + && HAS_OWN_PROPERTY(proto, index)) {
|
| obj[index] = proto[index];
|
| if (index >= max) { max = index + 1; }
|
| }
|
| @@ -998,7 +999,7 @@ function ArraySort(comparefn) {
|
| // It's an interval.
|
| var proto_length = indices;
|
| for (var i = from; i < proto_length; i++) {
|
| - if (proto.hasOwnProperty(i)) {
|
| + if (HAS_OWN_PROPERTY(proto, i)) {
|
| obj[i] = UNDEFINED;
|
| }
|
| }
|
| @@ -1006,7 +1007,7 @@ function ArraySort(comparefn) {
|
| for (var i = 0; i < indices.length; i++) {
|
| var index = indices[i];
|
| if (!IS_UNDEFINED(index) && from <= index &&
|
| - proto.hasOwnProperty(index)) {
|
| + HAS_OWN_PROPERTY(proto, index)) {
|
| obj[index] = UNDEFINED;
|
| }
|
| }
|
| @@ -1029,14 +1030,14 @@ function ArraySort(comparefn) {
|
| }
|
| // Maintain the invariant num_holes = the number of holes in the original
|
| // array with indices <= first_undefined or > last_defined.
|
| - if (!obj.hasOwnProperty(first_undefined)) {
|
| + if (!HAS_OWN_PROPERTY(obj, first_undefined)) {
|
| num_holes++;
|
| }
|
|
|
| // Find last defined element.
|
| while (first_undefined < last_defined &&
|
| IS_UNDEFINED(obj[last_defined])) {
|
| - if (!obj.hasOwnProperty(last_defined)) {
|
| + if (!HAS_OWN_PROPERTY(obj, last_defined)) {
|
| num_holes++;
|
| }
|
| last_defined--;
|
|
|