aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-02-26 20:28:38 -0500
committerAlon Zakai <alonzakai@gmail.com>2013-02-26 20:28:38 -0500
commit8d0c65454d6b15f4212b5c1809daa953295ce20d (patch)
tree270f54a0defc594ddd7667a8f156f86250b6b280 /src
parentf4cceb902a31810215858393dd80c24ef62f6f15 (diff)
parent73f24426c1bdfd2ea9c6d42d8466bbdb42a6a092 (diff)
Merge branch 'incoming' of github.com:lptr/emscripten into lptr-incoming
Diffstat (limited to 'src')
-rw-r--r--src/preamble.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/preamble.js b/src/preamble.js
index a7731e7f..6f4b49de 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -447,7 +447,7 @@ function allocate(slab, types, allocator, ptr) {
}
#endif
- var i = 0, type;
+ var i = 0, type, typeSize, previousType;
while (i < size) {
var curr = slab[i];
@@ -469,7 +469,13 @@ function allocate(slab, types, allocator, ptr) {
#endif
setValue(ret+i, curr, type);
- i += Runtime.getNativeTypeSize(type);
+
+ // no need to look up size unless type changes, so cache it
+ if (previousType !== type) {
+ typeSize = Runtime.getNativeTypeSize(type);
+ previousType = type;
+ }
+ i += typeSize;
}
return ret;