From c16f7eafcae4a35d1be8c071760198f787bc9aef Mon Sep 17 00:00:00 2001 From: Roland Paterson-Jones Date: Wed, 16 Oct 2024 08:56:38 +0200 Subject: [PATCH] Fn::rpo is a vector Scratching an itch - avoid unnecesary re-allocation in fillrpo() which is called multiple times in the optimisation chain. --- cfg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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);