summaryrefslogtreecommitdiff
path: root/src/ir/ExpressionManipulator.cpp
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-09-23 01:05:27 +0300
committerGitHub <noreply@github.com>2021-09-22 22:05:27 +0000
commitb6820540c8055dd7720ff369c7c0b6ebb34391f0 (patch)
tree3fa47686331de4a9f32528ada01a94394ed308f0 /src/ir/ExpressionManipulator.cpp
parentc50ab818ee6643b903ad3727f3fe10235fc801ff (diff)
downloadbinaryen-b6820540c8055dd7720ff369c7c0b6ebb34391f0.tar.gz
binaryen-b6820540c8055dd7720ff369c7c0b6ebb34391f0.tar.bz2
binaryen-b6820540c8055dd7720ff369c7c0b6ebb34391f0.zip
[Refactoring] Code reusage in spliceIntoBlock (#4174)
Diffstat (limited to 'src/ir/ExpressionManipulator.cpp')
-rw-r--r--src/ir/ExpressionManipulator.cpp12
1 files changed, 1 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);
}