Changeset: cd8764600767 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cd8764600767
Modified Files:
        gdk/gdk.h
        gdk/gdk_atoms.h
        gdk/gdk_string.c
Branch: default
Log Message:

Removed type stridx_t: it's actually equal to var_t, offset into vheap.


diffs (170 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -831,9 +831,7 @@ gdk_export BUN ORDERfndlast(BAT *b, Heap
 
 gdk_export BUN BUNfnd(BAT *b, const void *right);
 
-typedef var_t stridx_t;
-#define SIZEOF_STRIDX_T SIZEOF_VAR_T
-#define GDK_VARALIGN SIZEOF_STRIDX_T
+#define GDK_VARALIGN SIZEOF_VAR_T
 
 #include "gdk_atoms.h"
 #include "gdk_cand.h"
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -382,7 +382,7 @@ ATOMreplaceVAR(BAT *b, var_t *dst, const
  */
 #define GDK_STRHASHTABLE       (1<<10) /* 1024 */
 #define GDK_STRHASHMASK                (GDK_STRHASHTABLE-1)
-#define GDK_STRHASHSIZE                (GDK_STRHASHTABLE * sizeof(stridx_t))
+#define GDK_STRHASHSIZE                (GDK_STRHASHTABLE * sizeof(var_t))
 #define GDK_ELIMPOWER          16      /* 64KiB is the threshold */
 #define GDK_ELIMDOUBLES(h)     ((h)->free < GDK_ELIMLIMIT)
 #define GDK_ELIMLIMIT          (1<<GDK_ELIMPOWER)      /* equivalently: 
ELIMBASE == 0 */
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -78,7 +78,7 @@ strHeap(Heap *d, size_t cap)
 void
 strCleanHash(Heap *h, bool rebuild)
 {
-       stridx_t newhash[GDK_STRHASHTABLE];
+       var_t newhash[GDK_STRHASHTABLE];
        size_t pad, pos;
        BUN off, strhash;
        const char *s;
@@ -108,7 +108,7 @@ strCleanHash(Heap *h, bool rebuild)
        pos = GDK_STRHASHSIZE;
        while (pos < h->free) {
                pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1));
-               if (pad < sizeof(stridx_t))
+               if (pad < sizeof(var_t))
                        pad += GDK_VARALIGN;
                pos += pad;
                if (pos >= GDK_ELIMLIMIT)
@@ -116,7 +116,7 @@ strCleanHash(Heap *h, bool rebuild)
                s = h->base + pos;
                strhash = strHash(s);
                off = strhash & GDK_STRHASHMASK;
-               newhash[off] = (stridx_t) (pos - sizeof(stridx_t));
+               newhash[off] = (var_t) (pos - sizeof(var_t));
                pos += strlen(s) + 1;
        }
        /* only set dirty flag if the hash table actually changed */
@@ -133,7 +133,7 @@ strCleanHash(Heap *h, bool rebuild)
                pos = GDK_STRHASHSIZE;
                while (pos < h->free) {
                        pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1));
-                       if (pad < sizeof(stridx_t))
+                       if (pad < sizeof(var_t))
                                pad += GDK_VARALIGN;
                        pos += pad;
                        s = h->base + pos;
@@ -157,7 +157,7 @@ countStrings(const Heap *h)
        while (pos < h->free) {
                pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1));
                if (pos + pad < GDK_ELIMLIMIT) {
-                       if (pad < sizeof(stridx_t))
+                       if (pad < sizeof(var_t))
                                pad += GDK_VARALIGN;
                } else if (pos >= GDK_ELIMLIMIT)
                        pad = 0;
@@ -178,7 +178,7 @@ countStrings(const Heap *h)
 var_t
 strLocate(Heap *h, const char *v)
 {
-       stridx_t *ref, *next;
+       var_t *ref, *next;
 
        /* search hash-table, if double-elimination is still in place */
        BUN off;
@@ -194,10 +194,10 @@ strLocate(Heap *h, const char *v)
        assert(GDK_ELIMBASE(h->free) == 0);
 
        /* search the linked list */
-       for (ref = ((stridx_t *) h->base) + off; *ref; ref = next) {
-               next = (stridx_t *) (h->base + *ref);
+       for (ref = ((var_t *) h->base) + off; *ref; ref = next) {
+               next = (var_t *) (h->base + *ref);
                if (strcmp(v, (char *) (next + 1)) == 0)
-                       return (var_t) ((sizeof(stridx_t) + *ref));     /* 
found */
+                       return (var_t) ((sizeof(var_t) + *ref));        /* 
found */
        }
        return (var_t) -2;
 }
@@ -209,7 +209,7 @@ strPut(BAT *b, var_t *dst, const void *V
        Heap *h = b->tvheap;
        size_t pad;
        size_t pos, len = strlen(v) + 1;
-       stridx_t *bucket;
+       var_t *bucket;
        BUN off;
 
        if (h->free == 0) {
@@ -232,7 +232,7 @@ strPut(BAT *b, var_t *dst, const void *V
 
        off = strHash(v);
        off &= GDK_STRHASHMASK;
-       bucket = ((stridx_t *) h->base) + off;
+       bucket = ((var_t *) h->base) + off;
 
        if (*bucket) {
                assert(*bucket < h->free);
@@ -240,16 +240,16 @@ strPut(BAT *b, var_t *dst, const void *V
                if (*bucket < GDK_ELIMLIMIT) {
                        /* small string heap (<64KiB) -- fully double
                         * eliminated: search the linked list */
-                       const stridx_t *ref = bucket;
+                       const var_t *ref = bucket;
 
                        do {
-                               pos = *ref + sizeof(stridx_t);
+                               pos = *ref + sizeof(var_t);
                                assert(pos < h->free);
                                if (strcmp(v, h->base + pos) == 0) {
                                        /* found */
                                        return *dst = (var_t) pos;
                                }
-                               ref = (stridx_t *) (h->base + *ref);
+                               ref = (var_t *) (h->base + *ref);
                        } while (*ref);
                } else {
                        /* large string heap (>=64KiB) -- there is no
@@ -276,7 +276,7 @@ strPut(BAT *b, var_t *dst, const void *V
 
        pad = GDK_VARALIGN - (h->free & (GDK_VARALIGN - 1));
        if (GDK_ELIMBASE(h->free + pad) == 0) { /* i.e. h->free+pad < 
GDK_ELIMLIMIT */
-               if (pad < sizeof(stridx_t)) {
+               if (pad < sizeof(var_t)) {
                        /* make room for hash link */
                        pad += GDK_VARALIGN;
                }
@@ -313,7 +313,7 @@ strPut(BAT *b, var_t *dst, const void *V
                h = b->tvheap;
 
                /* make bucket point into the new heap */
-               bucket = ((stridx_t *) h->base) + off;
+               bucket = ((var_t *) h->base) + off;
        }
 
        /* insert string */
@@ -326,12 +326,12 @@ strPut(BAT *b, var_t *dst, const void *V
 
        /* maintain hash table */
        if (GDK_ELIMBASE(pos) == 0) {   /* small string heap: link the next 
pointer */
-               /* the stridx_t next pointer directly precedes the
+               /* the var_t next pointer directly precedes the
                 * string */
-               pos -= sizeof(stridx_t);
-               *(stridx_t *) (h->base + pos) = *bucket;
+               pos -= sizeof(var_t);
+               *(var_t *) (h->base + pos) = *bucket;
        }
-       *bucket = (stridx_t) pos;       /* set bucket to the new string */
+       *bucket = (var_t) pos;  /* set bucket to the new string */
        h->dirty = true;
 
        if (b->tascii && !strNil(v)) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to