How are you computing your pre-computed hash values? Did you copy the hashing algorithm from APR's find_entry?
My biggest concern with this function is that the caller's hash function must agree with APR's hash function or the hash table won't work. What will happen if APR changes the hash algorithm in a later release, that would break any program that uses this set function? For these reasons, I don't think this function should be included in APR. A better approach to this, IMHO, is to create a new apr_hash_make function that allows a user to pass in a hash function. This way, your program could pre-compute and cache the hash values. When apr_hash_set or apr_hash_get are called, they will call your hashing function, which could then retrieve the correct value from the hash. I would assume that the function signature would be something like: unsigned int hash_func(const char *key, apr_ssize_t klen); Ryan Quoting Ami Ganguli <[EMAIL PROTECTED]>: > Hi folks, > > I'm just starting to use the apr library and my first > task is to implement a hash based dictionary. I use > hash keys to speed up string comparisons, so my keys > all have pre-computed hash values. > > It probably makes little difference for performance, > but it doesn't feel right that apr_hash_set keeps > recomputing my hash values, when I've already done the > work and remembered the hash. > > If I write my own version of apr_hash_set, perhaps: > > void > apr_hash_set_precompute ( > apr_hash_t *ht, > unsigned int hash, > const void *key, > apr_ssize_t klen, > const void *val > ) > > would there be any interest in including it with the > library? > > Regards, > Ami. > > > > > > > ____________________________________________________________ > Yahoo! Messenger - Communicate instantly..."Ping" > your friends today! Download Messenger Now > http://uk.messenger.yahoo.com/download/index.html >
