diff options
author | tingyuan <thuang@mozilla.com> | 2013-03-20 17:15:08 +0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-05-21 17:09:58 -0700 |
commit | b3420393c13ce5dbb5021fcdea225e12d7816383 (patch) | |
tree | a086f3fbc45154ce489f13fbb88856e44662fb42 /src/preamble.js | |
parent | 8ce77d1492d58897e40f5d428604c68ff16ffe57 (diff) |
Specialize Array/TypedArray in allocate() to avoid unnecessary array constructions.
Diffstat (limited to 'src/preamble.js')
-rw-r--r-- | src/preamble.js | 6 |
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 |