aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--src/preamble.js10
2 files changed, 9 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index ef611d55..296d4150 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -51,4 +51,5 @@ a license to everyone to use it as detailed in LICENSE.)
* Michael Bishop <mbtyke@gmail.com>
* Roger Braun <roger@rogerbraun.net>
* Vladimir Vukicevic <vladimir@pobox.com> (copyright owned by Mozilla Foundation)
+* Lorant Pinter <lorant.pinter@prezi.com>
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;