Changeset: a69b9a12f6e9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a69b9a12f6e9
Modified Files:
        sql/common/sql_hash.c
        sql/include/sql_hash.h
        sql/server/rel_exp.c
        sql/storage/objectset.c
        sql/storage/sql_catalog.c
Branch: default
Log Message:

Inline commonly used hash functions


diffs (112 lines):

diff --git a/sql/common/sql_hash.c b/sql/common/sql_hash.c
--- a/sql/common/sql_hash.c
+++ b/sql/common/sql_hash.c
@@ -40,20 +40,6 @@ hash_new(sql_allocator *sa, int size, fk
        return ht;
 }
 
-sql_hash_e*
-hash_add(sql_hash *h, int key, void *value)
-{
-       sql_hash_e *e = (h->sa)?SA_ZNEW(h->sa, sql_hash_e):ZNEW(sql_hash_e);
-
-       if (e == NULL)
-               return NULL;
-       e->chain = h->buckets[key&(h->size-1)];
-       h->buckets[key&(h->size-1)] = e;
-       e->key = key;
-       e->value = value;
-       return e;
-}
-
 void
 hash_del(sql_hash *h, int key, void *value)
 {
@@ -91,13 +77,3 @@ hash_destroy(sql_hash *h) /* this code s
        _DELETE(h);
 }
 
-unsigned int
-hash_key(const char *restrict k)
-{
-       unsigned int h = 37; /* prime number */
-       while (*k) {
-               h = (h * 54059) ^ (k[0] * 76963); /* prime numbers */
-               k++;
-       }
-       return h;
-}
diff --git a/sql/include/sql_hash.h b/sql/include/sql_hash.h
--- a/sql/include/sql_hash.h
+++ b/sql/include/sql_hash.h
@@ -33,10 +33,32 @@ typedef struct sql_hash {
 } sql_hash;
 
 extern sql_hash *hash_new(sql_allocator *sa, int size, fkeyvalue key);
-extern sql_hash_e *hash_add(sql_hash *ht, int key, void *value);
 extern void hash_del(sql_hash *ht, int key, void *value);
 extern void hash_destroy(sql_hash *h);
 
-extern unsigned int hash_key(const char *restrict k);
+static inline sql_hash_e*
+hash_add(sql_hash *h, int key, void *value)
+{
+       sql_hash_e *e = (h->sa)?SA_NEW(h->sa, sql_hash_e):MNEW(sql_hash_e);
+
+       if (e == NULL)
+               return NULL;
+       e->chain = h->buckets[key&(h->size-1)];
+       h->buckets[key&(h->size-1)] = e;
+       e->key = key;
+       e->value = value;
+       return e;
+}
+
+static inline unsigned int
+hash_key(const char *restrict k)
+{
+       unsigned int h = 37; /* prime number */
+       while (*k) {
+               h = (h * 54059) ^ (k[0] * 76963); /* prime numbers */
+               k++;
+       }
+       return h;
+}
 
 #endif /* SQL_HASH_H */
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -2361,7 +2361,7 @@ exp_unsafe(sql_exp *e, int allow_identit
        return 0;
 }
 
-static int
+static inline int
 exp_key( sql_exp *e )
 {
        if (e->alias.name)
diff --git a/sql/storage/objectset.c b/sql/storage/objectset.c
--- a/sql/storage/objectset.c
+++ b/sql/storage/objectset.c
@@ -262,7 +262,7 @@ node_create(sql_allocator *sa, objectver
        return n;
 }
 
-static int
+static inline int
 os_name_key(versionhead  *n)
 {
        return hash_key(n->ov->b->name);
diff --git a/sql/storage/sql_catalog.c b/sql/storage/sql_catalog.c
--- a/sql/storage/sql_catalog.c
+++ b/sql/storage/sql_catalog.c
@@ -12,7 +12,7 @@
 
 const char *TID = "%TID%";
 
-int
+inline int
 base_key( sql_base *b )
 {
        return hash_key(b->name);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to