aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-02 00:50:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-02 00:50:38 +0200
commit48a29defcaeb3e3bbf32ae6ed3f77de2101e083a (patch)
tree1bff5f988c896a92d422d3ee9613eb329357e9f7
parent9c35a1cfb642c1d02cdfdc2290d9310606bdd72f (diff)
downloadbusybox-w32-48a29defcaeb3e3bbf32ae6ed3f77de2101e083a.tar.gz
busybox-w32-48a29defcaeb3e3bbf32ae6ed3f77de2101e083a.tar.bz2
busybox-w32-48a29defcaeb3e3bbf32ae6ed3f77de2101e083a.zip
httpd: speed up httpd.conf at the cost of 49 bytes of code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/httpd.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index b8aa02fe4..52b2b2a7a 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -530,27 +530,39 @@ static void parse_conf(const char *path, int flag)
530 while (fgets(buf, sizeof(buf), f) != NULL) { 530 while (fgets(buf, sizeof(buf), f) != NULL) {
531 unsigned strlen_buf; 531 unsigned strlen_buf;
532 unsigned char ch; 532 unsigned char ch;
533 char *after_colon = NULL; 533 char *after_colon;
534 534
535 { /* remove all whitespace, and # comments */ 535 { /* remove all whitespace, and # comments */
536 char *p, *p0; 536 char *p, *p0;
537 537
538 p = p0 = buf; 538 p0 = buf;
539 while ((ch = *p0++) != '\0' && ch != '#') { 539 /* skip non-whitespace beginning. Often the whole line
540 if (!isspace(ch)) { 540 * is non-whitespace. We want this case to work fast,
541 * without needless copying, therefore we don't merge
542 * this operation into next while loop. */
543 while ((ch = *p0) != '\0' && ch != '\n' && ch != '#'
544 && ch != ' ' && ch != '\t'
545 ) {
546 p0++;
547 }
548 p = p0;
549 /* if we enter this loop, we have some whitespace.
550 * discard it */
551 while (ch != '\0' && ch != '\n' && ch != '#') {
552 if (ch != ' ' && ch != '\t') {
541 *p++ = ch; 553 *p++ = ch;
542 if (ch == ':' && after_colon == NULL)
543 after_colon = p;
544 } 554 }
555 ch = *++p0;
545 } 556 }
546 *p = '\0'; 557 *p = '\0';
547 strlen_buf = p - buf; 558 strlen_buf = p - buf;
548 if (strlen_buf == 0) 559 if (strlen_buf == 0)
549 continue; 560 continue; /* empty line */
550 } 561 }
551 562
563 after_colon = strchr(buf, ':');
552 /* strange line? */ 564 /* strange line? */
553 if (after_colon == NULL || *after_colon == '\0') 565 if (after_colon == NULL || *++after_colon == '\0')
554 goto config_error; 566 goto config_error;
555 567
556 ch = (buf[0] & ~0x20); /* toupper if it's a letter */ 568 ch = (buf[0] & ~0x20); /* toupper if it's a letter */