From 02d381a43fd31ecfb2f991671d5bc82297861f77 Mon Sep 17 00:00:00 2001 From: brianp Date: Sat, 6 Jul 2002 08:13:35 +0000 Subject: Additional speedup for apr_table_unset(): don't start doing the check for dst_elt!=NULL on each iteration until we've seen the first instance of the target key git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63580 13f79535-47bb-0310-9956-ffa450edef68 --- tables/apr_tables.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'tables/apr_tables.c') diff --git a/tables/apr_tables.c b/tables/apr_tables.c index 03e907f17..1949af9db 100644 --- a/tables/apr_tables.c +++ b/tables/apr_tables.c @@ -505,7 +505,7 @@ APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key) { apr_table_entry_t *next_elt = (apr_table_entry_t *) t->a.elts; apr_table_entry_t *end_elt = next_elt + t->a.nelts; - apr_table_entry_t *dst_elt = NULL; + apr_table_entry_t *dst_elt; apr_uint32_t checksum; COMPUTE_KEY_CHECKSUM(key, checksum); @@ -513,12 +513,17 @@ APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key) if ((checksum == next_elt->key_checksum) && !strcasecmp(next_elt->key, key)) { t->a.nelts--; - if (!dst_elt) { - dst_elt = next_elt; + dst_elt = next_elt; + for (next_elt++; next_elt < end_elt; next_elt++) { + if ((checksum == next_elt->key_checksum) && + !strcasecmp(next_elt->key, key)) { + t->a.nelts--; + } + else { + *dst_elt++ = *next_elt; + } } - } - else if (dst_elt) { - *dst_elt++ = *next_elt; + break; } } } -- cgit v1.2.1