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

Unified Diff: src/array.js

Issue 1132723008: Implement %TypedArray%.reverse (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 93378cfb00b1b14c0150e5b179c6de5f6a8852a2..0d25f99efdb0da06efa0cfcaa8070953c71e37a6 100644
--- a/src/array.js
+++ b/src/array.js
@@ -12,6 +12,7 @@ var $arraySplice;
var $arrayUnshift;
var $innerArrayForEach;
var $innerArrayEvery;
+var $innerArrayReverse;
(function(global, shared, exports) {
@@ -564,18 +565,7 @@ function SparseReverse(array, len) {
}
-function ArrayReverse() {
- CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reverse");
-
- var array = TO_OBJECT_INLINE(this);
- var len = TO_UINT32(array.length);
-
- if (UseSparseVariant(array, len, IS_ARRAY(array), len)) {
- %NormalizeElements(array);
- SparseReverse(array, len);
- return array;
- }
-
+function InnerArrayReverse(array, len) {
var j = len - 1;
for (var i = 0; i < j; i++, j--) {
var current_i = array[i];
@@ -600,6 +590,22 @@ function ArrayReverse() {
}
+function ArrayReverse() {
+ CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reverse");
+
+ var array = TO_OBJECT_INLINE(this);
+ var len = TO_UINT32(array.length);
+
+ if (UseSparseVariant(array, len, IS_ARRAY(array), len)) {
+ %NormalizeElements(array);
+ SparseReverse(array, len);
+ return array;
+ }
+
+ return InnerArrayReverse(array, len);
+}
+
+
function ObservedArrayShift(len) {
var first = this[0];
@@ -1609,5 +1615,6 @@ $arrayUnshift = ArrayUnshift;
$innerArrayForEach = InnerArrayForEach;
$innerArrayEvery = InnerArrayEvery;
+$innerArrayReverse = InnerArrayReverse;
});
« 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