in reply to Calling the 'newhash' ?

It's defined as a C macro in hv.h. From that file:

/* hash a key */ /* FYI: This is the "One-at-a-Time" algorithm by Bob Jenkins * from requirements by Colin Plumb. * (http://burtleburtle.net/bob/hash/doobs.html) */ /* The use of a temporary pointer and the casting games * is needed to serve the dual purposes of * (a) the hashed data being interpreted as "unsigned char" (new since + 5.8, * a "char" can be either signed or signed, depending on the compi +ler) * (b) catering for old code that uses a "char" */ #define PERL_HASH(hash,str,len) \ STMT_START { \ register const char *s_PeRlHaSh_tmp = str; \ register const unsigned char *s_PeRlHaSh = (const unsigned cha +r *)s_PeRlHaSh_tmp; \ register I32 i_PeRlHaSh = len; \ register U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) { \ hash_PeRlHaSh += *s_PeRlHaSh++; \ hash_PeRlHaSh += (hash_PeRlHaSh << 10); \ hash_PeRlHaSh ^= (hash_PeRlHaSh >> 6); \ } \ hash_PeRlHaSh += (hash_PeRlHaSh << 3); \ hash_PeRlHaSh ^= (hash_PeRlHaSh >> 11); \ (hash) = (hash_PeRlHaSh + (hash_PeRlHaSh << 15)); \ } STMT_END
It should be straightforward to produce an extension function from that with Inline::C or standard XS.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Calling the 'newhash' ?
by John M. Dlugosz (Monsignor) on Feb 27, 2003 at 22:42 UTC
    Ah, the "One-at-a-Time" algorithm. That's quite simple in comparison to the first one on the cited page, his "new hash". That takes 12 bytes at a time with a 12-byte internal state, but it is actually faster (order of 6n instead of 9n) because it handles more in a gulp.

    I was thinking that Perl used the "newhash" now.

    —John