Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: src/array.js

Issue 1148513002: Implement %TypedArray%.prototype.sort (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/harmony-typedarray.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/array.js
diff --git a/src/array.js b/src/array.js
index 0d25f99efdb0da06efa0cfcaa8070953c71e37a6..573b729984b9450751d21bf1b9d6d958c512cb08 100644
--- a/src/array.js
+++ b/src/array.js
@@ -13,6 +13,7 @@ var $arrayUnshift;
var $innerArrayForEach;
var $innerArrayEvery;
var $innerArrayReverse;
+var $innerArraySort;
(function(global, shared, exports) {
@@ -867,9 +868,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.
@@ -1114,7 +1113,6 @@ function ArraySort(comparefn) {
return first_undefined;
};
- var length = TO_UINT32(this.length);
if (length < 2) return this;
var is_array = IS_ARRAY(this);
@@ -1153,6 +1151,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.
@@ -1616,5 +1622,6 @@ $arrayUnshift = ArrayUnshift;
$innerArrayForEach = InnerArrayForEach;
$innerArrayEvery = InnerArrayEvery;
$innerArrayReverse = InnerArrayReverse;
+$innerArraySort = InnerArraySort;
});
« no previous file with comments | « no previous file | src/harmony-typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698