aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorant Pinter <lorant.pinter@prezi.com>2013-02-27 12:37:16 +0100
committerLorant Pinter <lorant.pinter@prezi.com>2013-02-27 12:37:16 +0100
commit760065dfbc02c32a16dee034b6210bc273419a24 (patch)
tree324b658121a7d36297310da1c8bc24d24701070a
parenta28b5d53d75b428b1bee1efd39ac6d01d68d56d2 (diff)
Reverse the order of function lookup in getCFunc() to avoid having to call eval()
-rw-r--r--src/preamble.js6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 6f4b49de..d0e83469 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -251,11 +251,9 @@ Module["ccall"] = ccall;
// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
function getCFunc(ident) {
try {
- var func = eval('_' + ident);
+ var func = globalScope['Module']['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
} catch(e) {
- try {
- func = globalScope['Module']['_' + ident]; // closure exported function
- } catch(e) {}
}
assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
return func;