aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Paterson-Jones <[email protected]>2024-10-16 08:56:38 +0200
committerQuentin Carbonneaux <[email protected]>2025-03-14 09:47:05 +0100
commitc16f7eafcae4a35d1be8c071760198f787bc9aef (patch)
tree7494ed2725ff1d97289eb9e6bbab02b1447ba6aa
parent327736b3a6e77b201fffebd3cc207662e823d3a5 (diff)
Fn::rpo is a vector
Scratching an itch - avoid unnecesary re-allocation in fillrpo() which is called multiple times in the optimisation chain.
-rw-r--r--cfg.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/cfg.c b/cfg.c
index 406c307..89928d5 100644
--- a/cfg.c
+++ b/cfg.c
@@ -108,7 +108,10 @@ fillrpo(Fn *f)
b->id = -1u;
n = 1 + rporec(f->start, f->nblk-1);
f->nblk -= n;
- f->rpo = alloc(f->nblk * sizeof f->rpo[0]);
+ if (f->rpo)
+ vgrow(&f->rpo, f->nblk);
+ else
+ f->rpo = vnew(f->nblk, sizeof f->rpo[0], PFn);
for (p=&f->start; (b=*p);) {
if (b->id == -1u) {
edgedel(b, &b->s1);