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

Unified Diff: src/harmony-typedarray.js

Issue 1131113002: TypedArray.prototype.copyWithin method (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: better description 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 | « src/harmony-array.js ('k') | test/mjsunit/harmony/typedarray-copywithin.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/harmony-typedarray.js
diff --git a/src/harmony-typedarray.js b/src/harmony-typedarray.js
index bbdb91fc20b24e323d58b648d1cacf59315318dd..c33e08b93ce3bcee4aa04429e407024fb4c04b07 100644
--- a/src/harmony-typedarray.js
+++ b/src/harmony-typedarray.js
@@ -29,6 +29,16 @@ TYPED_ARRAYS(DECLARE_GLOBALS)
// -------------------------------------------------------------------
+function TypedArrayCopyWithin(target, start, end) {
+ if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
+
+ var length = %_TypedArrayGetLength(this);
+
+ // TODO(dehrenberg): Replace with a memcpy for better performance
+ return $innerArrayCopyWithin(target, start, end, this, length);
+}
+%FunctionSetLength(TypedArrayCopyWithin, 2);
+
// ES6 draft 05-05-15, section 22.2.3.7
function TypedArrayEvery(f, receiver) {
if (!%IsTypedArray(this)) throw MakeTypeError(kNotTypedArray);
@@ -67,6 +77,7 @@ macro EXTEND_TYPED_ARRAY(NAME)
// Set up non-enumerable functions on the prototype object.
$installFunctions(GlobalNAME.prototype, DONT_ENUM, [
+ "copyWithin", TypedArrayCopyWithin,
"every", TypedArrayEvery,
"forEach", TypedArrayForEach
]);
« no previous file with comments | « src/harmony-array.js ('k') | test/mjsunit/harmony/typedarray-copywithin.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698