File tree 1 file changed +9
-4
lines changed 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 77
77
#include < ir/iteration.h>
78
78
#include < ir/utils.h>
79
79
#include < pass.h>
80
+ #include < support/small_vector.h>
80
81
#include < wasm-builder.h>
81
82
#include < wasm.h>
82
83
@@ -330,9 +331,13 @@ static void optimizeBlock(Block* curr,
330
331
}
331
332
// There is something to do!
332
333
bool keepingPart = keepStart < keepEnd;
333
- // Create a new merged list, and fill in the code before the
334
- // child block we are merging in. TODO better efficiency
335
- ExpressionList merged (module->allocator );
334
+ // Create a new merged list, and fill in the code before the child block
335
+ // we are merging in. It is efficient to use a small vector here because
336
+ // most blocks are fairly small, and this way we copy once into the arena
337
+ // we use for Block lists a single time at the end (arena allocations
338
+ // can't be freed, so any temporary allocations while we add to the list
339
+ // would end up wasted).
340
+ SmallVector<Expression*, 10 > merged;
336
341
for (size_t j = 0 ; j < i; j++) {
337
342
merged.push_back (list[j]);
338
343
}
@@ -383,7 +388,7 @@ static void optimizeBlock(Block* curr,
383
388
}
384
389
}
385
390
}
386
- list.swap (merged);
391
+ list.set (merged);
387
392
more = true ;
388
393
changed = true ;
389
394
break ;
You can’t perform that action at this time.
0 commit comments