Status: Approved.

/*REVISION ONE*/
int hash_function(char* c){
    int result = 0;
    while(*c){
        result *= 4;
        result ^= c;
    }
    return result;
}

/* Comments:
 * Code reviewer A: you shouldn't have magic numbers in your code,
 *                  at least name them something useful.
 * Status: Rejected.
 */

/*REVISION TWO*/
enum NUMBERS { ZERO, ONE, TWO, THREE, FOUR };
int hash_function(char* c){
    int result = ZERO;
    while(*c){
        result *= FOUR;
        result ^= c;
    }
    return result;
}

/* Comments:
 * Code reviewer A: seriously? Give them MEANINGFUL names!
 * Status: Rejected.
 */

/*REVISION THREE*/
int hash_function(char* c){
    int result = c == c;
    while(*c){
        result += result + result + result;
        result ^= c;
    }
    return result;
}

/* Comments:
 * Code reviewer A: I give up.
 * Status: Approved.
 */
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s