summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-08-29 12:54:18 -0700
committerGitHub <noreply@github.com>2022-08-29 12:54:18 -0700
commit0dba0860e1b285292acdb3e9db6bcd9c102750a6 (patch)
tree795636db87ac180a44c119a460b8f440d38ed4ee /src/wasm
parentbd630d707253a9838a3d0306e4be680942ff0715 (diff)
downloadbinaryen-0dba0860e1b285292acdb3e9db6bcd9c102750a6.tar.gz
binaryen-0dba0860e1b285292acdb3e9db6bcd9c102750a6.tar.bz2
binaryen-0dba0860e1b285292acdb3e9db6bcd9c102750a6.zip
[NFC] Simplify binary reading logic for element segments (#4989)
Similar to #4969 but for element segments.
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/wasm-binary.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index d449d4bdb..baff0d83f 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -2977,9 +2977,6 @@ void WasmBinaryBuilder::validateBinary() {
}
void WasmBinaryBuilder::processNames() {
- for (auto& segment : elementSegments) {
- wasm.addElementSegment(std::move(segment));
- }
for (auto& segment : dataSegments) {
wasm.addDataSegment(std::move(segment));
}
@@ -3178,7 +3175,7 @@ void WasmBinaryBuilder::readElementSegments() {
}
}
- elementSegments.push_back(std::move(segment));
+ wasm.addElementSegment(std::move(segment));
}
}
@@ -3348,7 +3345,7 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) {
if (index < wasm.tables.size()) {
auto* table = wasm.tables[index].get();
- for (auto& segment : elementSegments) {
+ for (auto& segment : wasm.elementSegments) {
if (segment->table == table->name) {
segment->table = name;
}
@@ -3369,8 +3366,8 @@ void WasmBinaryBuilder::readNames(size_t payloadLen) {
auto rawName = getInlineString();
auto name = processor.process(rawName);
- if (index < elementSegments.size()) {
- elementSegments[index]->setExplicitName(name);
+ if (index < wasm.elementSegments.size()) {
+ wasm.elementSegments[index]->setExplicitName(name);
} else {
std::cerr << "warning: elem index out of bounds in name section, "
"elem subsection: "