diff options
author | Alon Zakai <azakai@google.com> | 2021-02-06 00:46:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 16:46:37 -0800 |
commit | 51c8f2469f8fd05197b7694c65041b1567f2c6b5 (patch) | |
tree | 004877ed58384b8cccede06e872f4ed4c148670a /src/wasm/wasm-binary.cpp | |
parent | 9868c3636bf1309c23213dc8ef6de4c036d6c40b (diff) | |
download | binaryen-51c8f2469f8fd05197b7694c65041b1567f2c6b5.tar.gz binaryen-51c8f2469f8fd05197b7694c65041b1567f2c6b5.tar.bz2 binaryen-51c8f2469f8fd05197b7694c65041b1567f2c6b5.zip |
Use unordered maps of Name where possible (#3546)
Unordered maps will hash the pointer, while ordered ones will compare the
strings to find where to insert in the tree. I cannot confirm a speedup in time
from this, though others can, but I do see a consistent improvement of a
few % in perf stat results like number of instructions and cycles (and those
results have little noise). And it seems logical that this could be faster.
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 2c473a254..75ca5a2b1 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1894,7 +1894,7 @@ void WasmBinaryBuilder::readExports() { BYN_TRACE("== readExports\n"); size_t num = getU32LEB(); BYN_TRACE("num: " << num << std::endl); - std::set<Name> names; + std::unordered_set<Name> names; for (size_t i = 0; i < num; i++) { BYN_TRACE("read one\n"); auto curr = new Export; @@ -2524,7 +2524,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { } else if (nameType == BinaryConsts::UserSections::Subsection::NameFunction) { auto num = getU32LEB(); - std::set<Name> usedNames; + std::unordered_set<Name> usedNames; for (size_t i = 0; i < num; i++) { auto index = getU32LEB(); auto rawName = getInlineString(); @@ -2563,7 +2563,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { << std::to_string(funcIndex) << std::endl; } auto numLocals = getU32LEB(); - std::set<Name> usedNames; + std::unordered_set<Name> usedNames; for (size_t j = 0; j < numLocals; j++) { auto localIndex = getU32LEB(); auto rawLocalName = getInlineString(); @@ -2631,7 +2631,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) { } } else if (nameType == BinaryConsts::UserSections::Subsection::NameGlobal) { auto num = getU32LEB(); - std::set<Name> usedNames; + std::unordered_set<Name> usedNames; for (size_t i = 0; i < num; i++) { auto index = getU32LEB(); auto rawName = getInlineString(); |