summaryrefslogtreecommitdiff
path: root/tables
diff options
context:
space:
mode:
authorBrian Pane <brianp@apache.org>2002-07-27 21:45:06 +0000
committerBrian Pane <brianp@apache.org>2002-07-27 21:45:06 +0000
commit9b050c23b4e02c8e6d90480e9007c062cffa458f (patch)
treed2baed577117e0ff30ffaadb5c354b4e3aa3df23 /tables
parentd92d8d580f632836540d81a521a24ce5d01f9386 (diff)
downloadapr-9b050c23b4e02c8e6d90480e9007c062cffa458f.tar.gz
Updated apr_table_vdo() to take advantage of the indexing
recently added to tables. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63734 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tables')
-rw-r--r--tables/apr_tables.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/tables/apr_tables.c b/tables/apr_tables.c
index 3aa9db1f0..c4181ffe4 100644
--- a/tables/apr_tables.c
+++ b/tables/apr_tables.c
@@ -951,19 +951,32 @@ APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp,
{
char *argp;
apr_table_entry_t *elts = (apr_table_entry_t *) t->a.elts;
- int vdorv = 1, rv, i;
+ int vdorv = 1;
argp = va_arg(vp, char *);
do {
- apr_uint32_t checksum = 0;
+ int rv = 1, i;
if (argp) {
- COMPUTE_KEY_CHECKSUM(argp, checksum);
+ /* Scan for entries that match the next key */
+ int hash = TABLE_HASH(argp);
+ if (TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+ apr_uint32_t checksum;
+ COMPUTE_KEY_CHECKSUM(argp, checksum);
+ for (i = t->index_first[hash];
+ rv && (i <= t->index_last[hash]); ++i) {
+ if (elts[i].key && (checksum == elts[i].key_checksum) &&
+ !strcasecmp(elts[i].key, argp)) {
+ rv = (*comp) (rec, elts[i].key, elts[i].val);
+ }
+ }
+ }
}
- for (rv = 1, i = 0; rv && (i < t->a.nelts); ++i) {
- if (elts[i].key && (!argp ||
- ((checksum == elts[i].key_checksum) &&
- !strcasecmp(elts[i].key, argp)))) {
- rv = (*comp) (rec, elts[i].key, elts[i].val);
+ else {
+ /* Scan the entire table */
+ for (i = 0; rv && (i < t->a.nelts); ++i) {
+ if (elts[i].key) {
+ rv = (*comp) (rec, elts[i].key, elts[i].val);
+ }
}
}
if (rv == 0) {