summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-12-04 14:41:19 -0800
committerOri Bernstein <ori@eigenstate.org>2016-12-04 14:41:19 -0800
commit9a50dfed92787e84786453a3afc645c1b2610d96 (patch)
treebc20696ed3b19b44032f36e3bed7710b5ae8c46a /6
parentdc611e92af421149bc0277b199250966919fe7e7 (diff)
downloadmc-9a50dfed92787e84786453a3afc645c1b2610d96.tar.gz
Don't incrementally grow nodemove lists.
This is O(n^2) and it actually matters.
Diffstat (limited to '6')
-rw-r--r--6/ra.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/6/ra.c b/6/ra.c
index 24c9d47..71c3a19 100644
--- a/6/ra.c
+++ b/6/ra.c
@@ -593,22 +593,22 @@ static int adjavail(Isel *s, regid r)
static size_t nodemoves(Isel *s, regid n, Insn ***pil)
{
- size_t i;
- size_t count;
+ size_t i, count;
+ regid rid;
+ Insn **il;
- /* FIXME: inefficient. Do I care? */
count = 0;
- if (pil)
- *pil = NULL;
+ il = malloc(s->nrmoves[n] * sizeof(Insn*));
for (i = 0; i < s->nrmoves[n]; i++) {
- if (bshas(s->mactiveset, s->rmoves[n][i]->uid))
- lappend(pil, &count, s->rmoves[n][i]);
- if (bshas(s->wlmoveset, s->rmoves[n][i]->uid))
- lappend(pil, &count, s->rmoves[n][i]);
+ rid = s->rmoves[n][i]->uid;
+ if (bshas(s->mactiveset, rid) || bshas(s->wlmoveset, rid))
+ il[count++] = s->rmoves[n][i];
}
+ *pil = il;
return count;
}
+
static int moverelated(Isel *s, regid n)
{
size_t i;