aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-05-01 11:37:57 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-05-01 11:37:57 -0700
commit34a0667d67e4f4679b438277212a446c3d3f3996 (patch)
tree01c0befbfa29e67720efb89edb31f638319b3ff7
parentf2bbcc88167af3ae80a25376c7bef8fc75065e99 (diff)
cache browser async call helpers
-rw-r--r--src/library_browser.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index cae14559..fa3e051b 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -5,6 +5,7 @@
mergeInto(LibraryManager.library, {
$Browser: {
pointerLock: false,
+ asyncCalls: {},
createContext: function(canvas, useWebGL) {
#if !USE_TYPED_ARRAYS
@@ -147,10 +148,12 @@ mergeInto(LibraryManager.library, {
emscripten_async_call: function(func, millis) {
Module['noExitRuntime'] = true;
- // TODO: cache these to avoid generating garbage
- setTimeout(function() {
- FUNCTION_TABLE[func]();
- }, millis);
+ if (!Browser.asyncCalls[func]) {
+ Browser.asyncCalls[func] = function() {
+ FUNCTION_TABLE[func]();
+ };
+ }
+ setTimeout(Browser.asyncCalls[func], millis);
}
});