summaryrefslogtreecommitdiff
path: root/usr.bin/pcc/cc
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-10-05 12:48:30 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-10-05 12:48:30 +0000
commit5faae98cfba3a5a99034bb76d995cd5159cb6a1f (patch)
treec9696d6510ece2d38565d4fee4c046066ebcc920 /usr.bin/pcc/cc
parent706b4bb70cc85785c5170ff71fda17f776be00fb (diff)
optimize a "not so bright" piece of code. Reduces compilation time on my
evil test case from > 3m to < 1s. ok ragge@
Diffstat (limited to 'usr.bin/pcc/cc')
-rw-r--r--usr.bin/pcc/cc/ccom/init.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/pcc/cc/ccom/init.c b/usr.bin/pcc/cc/ccom/init.c
index 3813cf8369c..ec721195479 100644
--- a/usr.bin/pcc/cc/ccom/init.c
+++ b/usr.bin/pcc/cc/ccom/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.8 2007/09/29 15:19:13 otto Exp $ */
+/* $OpenBSD: init.c,v 1.9 2007/10/05 12:48:29 otto Exp $ */
/*
* Copyright (c) 2004, 2007 Anders Magnusson (ragge@ludd.ltu.se).
@@ -185,16 +185,19 @@ getll(void)
/*
* Return structure containing off bitnumber.
* Allocate more entries, if needed.
- * This is not bright implemented.
*/
static struct llist *
setll(OFFSZ off)
{
- struct llist *ll;
+ struct llist *ll = NULL;
/* Ensure that we have enough entries */
while (off >= basesz * numents)
- (void)getll();
+ ll = getll();
+
+ if (ll != NULL && ll->begsz <= off && ll->begsz + basesz > off)
+ return ll;
+
SLIST_FOREACH(ll, &lpole, next)
if (ll->begsz <= off && ll->begsz + basesz > off)
break;