summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2007-10-05 12:48:29 +0000
committerotto <otto@openbsd.org>2007-10-05 12:48:29 +0000
commit95c842c38c5d37cd13945231dbe07a173e7c7d16 (patch)
treefcbdc893cce6f84bf4c132edcf15dacab2c52e3c
parentDisable fiber/copper auto-selection on the 88E1111 if it is in RGMII mode, to (diff)
downloadwireguard-openbsd-95c842c38c5d37cd13945231dbe07a173e7c7d16.tar.xz
wireguard-openbsd-95c842c38c5d37cd13945231dbe07a173e7c7d16.zip
optimize a "not so bright" piece of code. Reduces compilation time on my
evil test case from > 3m to < 1s. ok ragge@
-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;