Index: src/typedarray.js |
diff --git a/src/typedarray.js b/src/typedarray.js |
index f9e732fa7f8f35bfd13598746c8a02f9af98b2ef..7bd16f670b4425b88319676a52374c480b5b2477 100644 |
--- a/src/typedarray.js |
+++ b/src/typedarray.js |
@@ -77,11 +77,10 @@ function CreateTypedArrayConstructor(name, elementSize, arrayId, constructor) { |
function ConstructByArrayLike(obj, arrayLike) { |
var length = arrayLike.length; |
var l = ToPositiveInteger(length, "invalid_typed_array_length"); |
- var byteLength = l * elementSize; |
- var buffer = new $ArrayBuffer(byteLength); |
- %TypedArrayInitialize(obj, arrayId, buffer, 0, byteLength); |
- for (var i = 0; i < l; i++) { |
- obj[i] = arrayLike[i]; |
+ if(!%TypedArrayInitializeFromArrayLike(obj, arrayId, arrayLike, l)) { |
+ for (var i = 0; i < l; i++) { |
+ obj[i] = arrayLike[i]; |
+ } |
} |
} |