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

Unified Diff: src/array.js

Issue 1148513002: Implement %TypedArray%.prototype.sort (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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') | src/harmony-typedarray.js » ('J')
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 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;
});
« no previous file with comments | « no previous file | src/harmony-typedarray.js » ('j') | src/harmony-typedarray.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698