summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-11 13:49:04 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-11 13:49:04 -0800
commitdf5801fd2b8d3d128bca238d22eb19039251ffba (patch)
treeeb8ef08567d4e16959b0a6aa4a7700a5f1427ec2 /src/wasm-interpreter.h
parent3bce77f4aa50b1d070b852de484256e32220ce0b (diff)
downloadbinaryen-df5801fd2b8d3d128bca238d22eb19039251ffba.tar.gz
binaryen-df5801fd2b8d3d128bca238d22eb19039251ffba.tar.bz2
binaryen-df5801fd2b8d3d128bca238d22eb19039251ffba.zip
don't store caseMap in Switch, it's a pure optimization
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 47a442020..1cdd86387 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -227,8 +227,13 @@ private:
if (index >= 0 && index < curr->targets.size()) {
target = curr->targets[index];
}
- auto iter = curr->caseMap.find(target);
- if (iter == curr->caseMap.end()) {
+ // This is obviously very inefficient. This should be a cached data structure
+ std::map<Name, size_t> caseMap; // name => index in cases
+ for (size_t i = 0; i < curr->cases.size(); i++) {
+ caseMap[curr->cases[i].name] = i;
+ }
+ auto iter = caseMap.find(target);
+ if (iter == caseMap.end()) {
// not in the cases, so this is a break outside
return Flow(target);
}