From c68978114ccb12a6cef8ba5651ef3e0deb03f879 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 31 Jul 2024 10:16:36 -0700 Subject: 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(!). --- src/wasm/wasm-binary.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src') 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 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; } }; -- cgit v1.2.3