[EMAIL PROTECTED] wrote:
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.

FWIW, perl's hash entry lookup function's proto is:

  key_string, key_len, key_hash_str

So if key_hash_str is NULL perl will calculate the hash for you, if it's set it'll use it instead. Same goes for the key string length. This allows you to do your own caching and speed things up in certain situations. Perl also exposes the hashing function, so you can pre-hash values at the server startup and then re-use the hash values at run time. A big chunk of mod_perl 2.0's infrastructure relied on that feature.

Perhaps apr could provide a similar accessor, and expose the hashing function.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Reply via email to