diff options
author | brianp <brianp@13f79535-47bb-0310-9956-ffa450edef68> | 2002-07-06 08:13:35 +0000 |
---|---|---|
committer | brianp <brianp@13f79535-47bb-0310-9956-ffa450edef68> | 2002-07-06 08:13:35 +0000 |
commit | 02d381a43fd31ecfb2f991671d5bc82297861f77 (patch) | |
tree | 37438a61c173a061fd230c184c063e75d16da77a /tables | |
parent | 5a9efdd608de339d54573652cd8819e2556651c8 (diff) | |
download | libapr-02d381a43fd31ecfb2f991671d5bc82297861f77.tar.gz |
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
Diffstat (limited to 'tables')
-rw-r--r-- | tables/apr_tables.c | 17 |
1 files changed, 11 insertions, 6 deletions
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; } } } |