summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 3d9a1ba9b..039cef5e5 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -2054,13 +2054,13 @@ static char formatNibble(int nibble) {
return nibble < 10 ? '0' + nibble : 'a' - 10 + nibble;
}
-static void escapeName(Name& name) {
+Name WasmBinaryBuilder::escape(Name name) {
bool allIdChars = true;
for (const char* p = name.str; allIdChars && *p; p++) {
allIdChars = isIdChar(*p);
}
if (allIdChars) {
- return;
+ return name;
}
// encode name, if at least one non-idchar (per WebAssembly spec) was found
std::string escaped;
@@ -2075,7 +2075,7 @@ static void escapeName(Name& name) {
escaped.push_back(formatNibble(ch >> 4));
escaped.push_back(formatNibble(ch & 15));
}
- name = escaped;
+ return escaped;
}
void WasmBinaryBuilder::readNames(size_t payloadLen) {
@@ -2098,7 +2098,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) {
for (size_t i = 0; i < num; i++) {
auto index = getU32LEB();
auto rawName = getInlineString();
- escapeName(rawName);
+ rawName = escape(rawName);
auto name = rawName;
// De-duplicate names by appending .1, .2, etc.
for (int i = 1; !usedNames.insert(name).second; ++i) {