UP | HOME

Decorating Klone

You remember the girls in Jr. High that decorated their backpacks with all sorts of odd things; key chains, patches, vibrant colors. The weight of the clutter had to be comparable to the weight of the books they were carrying (assuming they carried books at all).

That's what the comments in the Klone source made me think of.

/************************\
*                        *
*  hash table routines   *
*                        *
\************************/

/*
 * Hash function definition:
 * HASH_FUNCTION: hash function, hash = hashcode, hp = pointer on char,
 *                               hash2 = temporary for hashcode.
 * INITIAL_TABLE_SIZE in slots
 * HASH_TABLE_GROWS how hash table grows.
ORG-LIST-END-MARKER
 */

/* KLONE hash function for symbols
 */
#define HASH_FUNCTION_ORIG        hash = (hash << 3) + (hash >> 28) + *hp++;
/* int l, inc; unsigned int hash; unsigned char *p, *last; */
#define HASH_FUNCTION(l, p, last, hash, inc) \
    if ((l) > 8) for (hash = 0, inc = ((l)>>3) ; p < last;p += inc) \
                     hash = (hash << 3) + (hash >> 28) + *p; \
    else for (hash = 0; p < last;) hash = (hash << 3) + (hash >> 28) + *p++
#define INITIAL_HASH_SIZE 2017
#define HASH_TABLE_GROWS  KlHashTableSize = KlHashTableSize * 2 + 1;

/* end of hash functions */

You gotta love the super-informative block that tells you "these be hash routines" right before another block describing that the stuff below is "Hash function definition." I might not've gotten it if they didn't tell me twice.

Date: 2013-10-30 08:06

Author: Anthony "Ishpeck" Tedjamulia

Org version 7.9.3f with Emacs version 24

Validate XHTML 1.0