1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Clean up some really grotty coding in catcache.c, improve hashing

performance in catcache lookups.
This commit is contained in:
Tom Lane
2000-02-21 03:36:59 +00:00
parent a60c9e33e9
commit d8cedf67ad
9 changed files with 128 additions and 131 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.23 2000/01/26 05:55:55 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.24 2000/02/21 03:36:46 tgl Exp $
*
* NOTES
* These functions are stored in pg_amproc. For each operator class
@@ -146,8 +146,24 @@ hashoidvector(Oid *key)
int i;
uint32 result = 0;
for (i = 0; i < INDEX_MAX_KEYS; i++)
result = result ^ (~(uint32) key[i]);
for (i = INDEX_MAX_KEYS; --i >= 0; )
result = (result << 1) ^ (~(uint32) key[i]);
return result;
}
/*
* Note: hashint2vector currently can't be used as a user hash table
* hash function, because it has no pg_proc entry. We only need it
* for catcache indexing.
*/
uint32
hashint2vector(int16 *key)
{
int i;
uint32 result = 0;
for (i = INDEX_MAX_KEYS; --i >= 0; )
result = (result << 1) ^ (~(uint32) key[i]);
return result;
}
@@ -158,13 +174,10 @@ hashoidvector(Oid *key)
uint32
hashchar(char key)
{
int len;
uint32 h;
h = 0;
len = sizeof(char);
/* Convert char to integer */
h = h * PRIME1 ^ (key - ' ');
h = (key - ' ');
h %= PRIME2;
return h;