Index: src/array.js |
diff --git a/src/array.js b/src/array.js |
index 93378cfb00b1b14c0150e5b179c6de5f6a8852a2..ff78293c1cf64a727b78ad59d4763d68dd8756e0 100644 |
--- a/src/array.js |
+++ b/src/array.js |
@@ -12,6 +12,7 @@ var $arraySplice; |
var $arrayUnshift; |
var $innerArrayForEach; |
var $innerArrayEvery; |
+var $innerArraySort; |
(function(global, shared, exports) { |
@@ -861,9 +862,7 @@ function ArraySplice(start, delete_count) { |
} |
-function ArraySort(comparefn) { |
- CHECK_OBJECT_COERCIBLE(this, "Array.prototype.sort"); |
- |
+function InnerArraySort(length, comparefn) { |
// In-place QuickSort algorithm. |
// For short (length <= 22) arrays, insertion sort is used for efficiency. |
@@ -1108,7 +1107,6 @@ function ArraySort(comparefn) { |
return first_undefined; |
}; |
- var length = TO_UINT32(this.length); |
if (length < 2) return this; |
var is_array = IS_ARRAY(this); |
@@ -1147,6 +1145,14 @@ function ArraySort(comparefn) { |
} |
+function ArraySort(comparefn) { |
+ CHECK_OBJECT_COERCIBLE(this, "Array.prototype.sort"); |
+ |
+ var length = TO_UINT32(this.length); |
+ return %_CallFunction(this, length, comparefn, InnerArraySort); |
+} |
+ |
+ |
// The following functions cannot be made efficient on sparse arrays while |
// preserving the semantics, since the calls to the receiver function can add |
// or delete elements from the array. |
@@ -1609,5 +1615,6 @@ $arrayUnshift = ArrayUnshift; |
$innerArrayForEach = InnerArrayForEach; |
$innerArrayEvery = InnerArrayEvery; |
+$innerArraySort = InnerArraySort; |
}); |