diff options
Diffstat (limited to 'src/backend/access/hash/hashfunc.c')
-rw-r--r-- | src/backend/access/hash/hashfunc.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index 1e2d779a14c..1f9813277a3 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.48 2006/10/04 00:29:48 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.48.2.1 2007/06/01 15:58:01 tgl Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -267,6 +267,31 @@ hash_any(register const unsigned char *k, register int keylen) /* case 0: nothing left to add */ } mix(a, b, c); + + /* report the result */ + return UInt32GetDatum(c); +} + +/* + * hash_uint32() -- hash a 32-bit value + * + * This has the same result (at least on little-endian machines) as + * hash_any(&k, sizeof(uint32)) + * but is faster and doesn't force the caller to store k into memory. + */ +Datum +hash_uint32(uint32 k) +{ + register uint32 a, + b, + c; + + a = 0x9e3779b9 + k; + b = 0x9e3779b9; + c = 3923095 + (uint32) sizeof(uint32); + + mix(a, b, c); + /* report the result */ return UInt32GetDatum(c); } |