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