(rob) wrote:
> Hi, I have a performance intensive script that needs to hash a lot of
> strings. I am guessing that perl's internal hashing algorithm is
> implemented at a low level, is optimized, etc. and I would like to
> access it though my perl scripts. Does anyone know how to do this?
I do this by using Perl hash variables
It is not clear to me exactly what you want to do. You want to use
Perl's hashing algorithm from within a Perl script, but without the
rest of the Hash-table machinery? I suppose you could copy the hashing
algorithm out of the Perl source and use it to create your own XS or
Inline::C code.
perlguts:
The hash algorithm is defined in the "PERL_HASH(hash, key, klen)"
macro:
hash = 0;
while (klen--)
hash = (hash * 33) + *key++;
hash = hash + (hash >> 5); /* after 5.6 */
But I don't see what this will get you. Calling this many times from
within Perl will probably spend more time on function-call overhead than on
hashing.
Xho
--
--------------------
http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB