summaryrefslogtreecommitdiff
path: root/src/wasm/wasm.cpp
diff options
context:
space:
mode:
authorPetr Makhnev <51853996+i582@users.noreply.github.com>2024-10-11 03:15:28 +0400
committerGitHub <noreply@github.com>2024-10-10 16:15:28 -0700
commit34906bfbc99d31b3e62d2d006af2247d8418ba2f (patch)
treedd0408aef3abbbdcc13064cec8c5e6d4780013d4 /src/wasm/wasm.cpp
parentf0a5e488ae68074837706edafb54050e56cf9937 (diff)
downloadbinaryen-34906bfbc99d31b3e62d2d006af2247d8418ba2f.tar.gz
binaryen-34906bfbc99d31b3e62d2d006af2247d8418ba2f.tar.bz2
binaryen-34906bfbc99d31b3e62d2d006af2247d8418ba2f.zip
Optimize Module::get_* family of functions with std::string_view in getModuleElement (#6998)
Passing a constant string to functions requires memory allocation, and allocation is inherently slow. Since we are using C++17, we can use string_view and remove this unnecessary allocation. Although the code seems simple enough for the optimizer to remove this allocation after inlining, tests on Clang 18 show that this is not the case (on Apple Silicon at least).
Diffstat (limited to 'src/wasm/wasm.cpp')
-rw-r--r--src/wasm/wasm.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index e8de4572b..0245fc01e 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -1523,7 +1523,7 @@ void Function::clearDebugInfo() {
template<typename Map>
typename Map::mapped_type&
-getModuleElement(Map& m, Name name, const std::string& funcName) {
+getModuleElement(Map& m, Name name, std::string_view funcName) {
auto iter = m.find(name);
if (iter == m.end()) {
Fatal() << "Module::" << funcName << ": " << name << " does not exist";