diff options
-rw-r--r-- | src/ir/ExpressionManipulator.cpp | 12 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 2 |
2 files changed, 3 insertions, 11 deletions
diff --git a/src/ir/ExpressionManipulator.cpp b/src/ir/ExpressionManipulator.cpp index 535aa51c3..0bb94a66d 100644 --- a/src/ir/ExpressionManipulator.cpp +++ b/src/ir/ExpressionManipulator.cpp @@ -114,17 +114,7 @@ flexibleCopy(Expression* original, Module& wasm, CustomCopier custom) { // Splice an item into the middle of a block's list void spliceIntoBlock(Block* block, Index index, Expression* add) { - auto& list = block->list; - if (index == list.size()) { - list.push_back(add); // simple append - } else { - // we need to make room - list.push_back(nullptr); - for (Index i = list.size() - 1; i > index; i--) { - list[i] = list[i - 1]; - } - list[index] = add; - } + block->list.insertAt(index, add); block->finalize(block->type); } diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 45137fffe..0f1017e00 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -821,6 +821,7 @@ void Try::finalize() { // If none of the component bodies' type is a supertype of the others, assume // the current type is already correct. TODO: Calculate a proper LUB. std::unordered_set<Type> types{body->type}; + types.reserve(catchBodies.size()); for (auto catchBody : catchBodies) { types.insert(catchBody->type); } @@ -844,6 +845,7 @@ void Rethrow::finalize() { type = Type::unreachable; } void TupleMake::finalize() { std::vector<Type> types; + types.reserve(operands.size()); for (auto* op : operands) { if (op->type == Type::unreachable) { type = Type::unreachable; |