From: Jim Jagielski Date: Thu, 14 May 2009 14:20:47 +0000 (+0000) Subject: optimize as suggested by chrisd X-Git-Tag: 2.3.3~595 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ffc510a2ac2fa34b2f0eb8cc1c7c5dbd1daba177;p=thirdparty%2Fapache%2Fhttpd.git optimize as suggested by chrisd git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@774778 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mem/mod_plainmem.c b/modules/mem/mod_plainmem.c index af1a3ffa50c..25707027fbc 100644 --- a/modules/mem/mod_plainmem.c +++ b/modules/mem/mod_plainmem.c @@ -63,17 +63,13 @@ static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_siz fname = ap_server_root_relative(pool, name); /* first try to attach to existing slotmem */ - if (next) { - for (;;) { - if (strcmp(next->name, fname) == 0) { - /* we already have it */ - *new = next; - return APR_SUCCESS; - } - if (!next->next) - break; - next = next->next; + while (next) { + if (strcmp(next->name, fname) == 0) { + /* we already have it */ + *new = next; + return APR_SUCCESS; } + next = next->next; } } else @@ -114,19 +110,15 @@ static apr_status_t slotmem_attach(ap_slotmem_t **new, const char *name, apr_siz return APR_ENOSHMAVAIL; /* first try to attach to existing slotmem */ - if (next) { - for (;;) { - if (strcmp(next->name, fname) == 0) { - /* we already have it */ - *new = next; - *item_size = next->size; - *item_num = next->num; - return APR_SUCCESS; - } - if (!next->next) - break; - next = next->next; + while (next) { + if (strcmp(next->name, fname) == 0) { + /* we already have it */ + *new = next; + *item_size = next->size; + *item_num = next->num; + return APR_SUCCESS; } + next = next->next; } return APR_ENOSHMAVAIL; diff --git a/modules/mem/mod_sharedmem.c b/modules/mem/mod_sharedmem.c index 90206690204..7585f2f9fe4 100644 --- a/modules/mem/mod_sharedmem.c +++ b/modules/mem/mod_sharedmem.c @@ -254,18 +254,13 @@ static apr_status_t slotmem_create(ap_slotmem_t **new, const char *name, apr_siz } /* first try to attach to existing slotmem */ - if (next) { - for (;;) { - if (strcmp(next->name, fname) == 0) { - /* we already have it */ - *new = next; - return APR_SUCCESS; - } - if (!next->next) { - break; - } - next = next->next; + while (next) { + if (strcmp(next->name, fname) == 0) { + /* we already have it */ + *new = next; + return APR_SUCCESS; } + next = next->next; } } else { @@ -375,19 +370,15 @@ static apr_status_t slotmem_attach(ap_slotmem_t **new, const char *name, apr_siz } /* first try to attach to existing slotmem */ - if (next) { - for (;;) { - if (strcmp(next->name, fname) == 0) { - /* we already have it */ - *new = next; - *item_size = next->size; - *item_num = next->num; - return APR_SUCCESS; - } - if (!next->next) - break; - next = next->next; + while (next) { + if (strcmp(next->name, fname) == 0) { + /* we already have it */ + *new = next; + *item_size = next->size; + *item_num = next->num; + return APR_SUCCESS; } + next = next->next; } /* first try to attach to existing shared memory */