diff options
author | Alon Zakai <azakai@google.com> | 2024-07-31 10:16:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-31 10:16:36 -0700 |
commit | c68978114ccb12a6cef8ba5651ef3e0deb03f879 (patch) | |
tree | ae0c802c882bd4ebc2f50bd63df2d14252dc3f81 /src | |
parent | e6bbff7846cad9daf178b6917d78abe5cfcd5771 (diff) | |
download | binaryen-c68978114ccb12a6cef8ba5651ef3e0deb03f879.tar.gz binaryen-c68978114ccb12a6cef8ba5651ef3e0deb03f879.tar.bz2 binaryen-c68978114ccb12a6cef8ba5651ef3e0deb03f879.zip |
Use Names::getValidNameGivenExisting in binary reading (#6793)
We had a TODO to use it once Names was optimized, which it has been.
The Names version is also far faster. When building
https://github.com/JetBrains/kotlinconf-app it saves 70 seconds(!).
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 0a65fbadb..3cb3b08da 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -19,6 +19,7 @@ #include "ir/eh-utils.h" #include "ir/module-utils.h" +#include "ir/names.h" #include "ir/table-utils.h" #include "ir/type-updating.h" #include "support/bits.h" @@ -3551,14 +3552,8 @@ private: std::unordered_set<Name> usedNames; Name deduplicate(Name base) { - // TODO: Consider using Names::getValidNameGivenExisting but that does give - // longer names, and it is very noticeable in this location, so - // perhaps optimize that first. - Name name = base; - // De-duplicate names by appending .1, .2, etc. - for (int i = 1; !usedNames.insert(name).second; ++i) { - name = std::string(base.str) + std::string(".") + std::to_string(i); - } + auto name = Names::getValidNameGivenExisting(base, usedNames); + usedNames.insert(name); return name; } }; |