aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
authortingyuan <thuang@mozilla.com>2013-03-20 17:15:08 +0800
committerAlon Zakai <alonzakai@gmail.com>2013-05-21 17:09:58 -0700
commitb3420393c13ce5dbb5021fcdea225e12d7816383 (patch)
treea086f3fbc45154ce489f13fbb88856e44662fb42 /src/preamble.js
parent8ce77d1492d58897e40f5d428604c68ff16ffe57 (diff)
Specialize Array/TypedArray in allocate() to avoid unnecessary array constructions.
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/preamble.js b/src/preamble.js
index dbe5e655..fb9d93c9 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -475,7 +475,11 @@ function allocate(slab, types, allocator, ptr) {
#if USE_TYPED_ARRAYS == 2
if (singleType === 'i8') {
- HEAPU8.set(new Uint8Array(slab), ret);
+ if (slab.subarray || slab.slice) {
+ HEAPU8.set(slab, ret);
+ } else {
+ HEAPU8.set(new Uint8Array(slab), ret);
+ }
return ret;
}
#endif