diff options
| author | Roland Paterson-Jones <[email protected]> | 2024-10-16 09:14:43 +0200 |
|---|---|---|
| committer | Quentin Carbonneaux <[email protected]> | 2025-03-14 09:47:05 +0100 |
| commit | 024dffac8bbfa709ed3aed53d14b235e67047490 (patch) | |
| tree | e0e20d66a5890973603582bd46de80e42b08b399 | |
| parent | c16f7eafcae4a35d1be8c071760198f787bc9aef (diff) | |
Blk::pred is a vector
Scratching an itch - avoid unnecesary re-allocation in fillpred()
which is called often in the optimisation chain.
| -rw-r--r-- | cfg.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -45,10 +45,11 @@ edgedel(Blk *bs, Blk **pbd) static void addpred(Blk *bp, Blk *bc) { - if (!bc->pred) { - bc->pred = alloc(bc->npred * sizeof bc->pred[0]); - bc->visit = 0; - } + if (bc->pred) + vgrow(&bc->pred, bc->npred); + else + bc->pred = vnew(bc->npred, sizeof bc->pred[0], PFn); + assert(bc->visit < bc->npred); bc->pred[bc->visit++] = bp; } @@ -60,7 +61,7 @@ fillpreds(Fn *f) for (b=f->start; b; b=b->link) { b->npred = 0; - b->pred = 0; + b->visit = 0; } for (b=f->start; b; b=b->link) { if (b->s1) |
