svn commit: trunk/busybox/scripts/basic

vda at busybox.net vda at busybox.net
Sat Dec 30 19:52:29 UTC 2006


Author: vda
Date: 2006-12-30 11:52:28 -0800 (Sat, 30 Dec 2006)
New Revision: 17111

Log:
saw commit of vapier at busybox.net (thanks!),
decided to stop doing FOUR memcmp's per each input character.
I should have fixed this much earlier...


Modified:
   trunk/busybox/scripts/basic/fixdep.c


Changeset:
Modified: trunk/busybox/scripts/basic/fixdep.c
===================================================================
--- trunk/busybox/scripts/basic/fixdep.c	2006-12-30 19:46:38 UTC (rev 17110)
+++ trunk/busybox/scripts/basic/fixdep.c	2006-12-30 19:52:28 UTC (rev 17111)
@@ -225,31 +225,36 @@
 void parse_config_file(char *map, size_t len)
 {
 	/* modified for bbox */
-	char *end = map + len;
+	char *end_4 = map + len - 4; /* 4 == length of "USE_" */
+	char *end_7 = map + len - 7;
 	char *p = map;
 	char *q;
 	int off;
 
-	for (; p < end; p++) {
-		if (p<end-7 && !memcmp(p, "CONFIG_", 7)) goto conf7;
-		if (p<end-7 && !memcmp(p, "ENABLE_", 7)) goto conf7;
-		if (p<end-4 && !memcmp(p, "USE_", 4)) goto conf4;
-		if (p<end-5 && !memcmp(p, "SKIP_", 5)) goto conf5;
+	for (; p < end_4; p++) {
+		if (p < end_7 && p[6] == '_') {
+			if (!memcmp(p, "CONFIG", 6)) goto conf7;
+			if (!memcmp(p, "ENABLE", 6)) goto conf7;
+		}
+		/* We have at least 5 chars: for() has
+		 * "p < end-4", not "p <= end-4"
+		 * therefore we don't need to check p <= end-5 here */
+		if (p[4] == '_') {
+			if (!memcmp(p, "SKIP", 4)) goto conf5;
+		}
+		/* Ehhh, gcc is too stupid to just compare it as 32bit int */
+		if (!memcmp(p, "USE_", 4)) goto conf4;
 		continue;
-	conf4:	off = 4; goto conf;
-	conf5:	off = 5; goto conf;
+
+	conf4:	off = 4;
+	conf5:	off = 5;
 	conf7:	off = 7;
-	conf:
-		if (p > map + len - off)
-			continue;
-		for (q = p + off; q < map + len; q++) {
+		p += off;
+		for (q = p; q < end_4+4; q++) {
 			if (!(isalnum(*q) || *q == '_'))
-				goto found;
+				break;
 		}
-		continue;
-
-	found:
-		use_config(p+off, q-p-off);
+		use_config(p, q-p);
 	}
 }
 




More information about the busybox-cvs mailing list