From ffc510a2ac2fa34b2f0eb8cc1c7c5dbd1daba177 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Thu, 14 May 2009 14:20:47 +0000 Subject: [PATCH] optimize as suggested by chrisd git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@774778 13f79535-47bb-0310-9956-ffa450edef68 --- modules/mem/mod_plainmem.c | 36 ++++++++++++++---------------------- modules/mem/mod_sharedmem.c | 37 ++++++++++++++----------------------- 2 files changed, 28 insertions(+), 45 deletions(-) diff --git a/modules/mem/mod_plainmem.c b/modules/mem/mod_plainmem.c index af1a3ffa50..25707027fb 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 9020669020..7585f2f9fe 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 */ -- 2.50.1