Changeset: 622f9cda01ca for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=622f9cda01ca
Modified Files:
gdk/gdk_batop.c
Branch: Jul2017
Log Message:
Some minor code improvements.
diffs (115 lines):
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -174,8 +174,12 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
}
memcpy(b->tvheap->base + toff, n->tvheap->base,
n->tvheap->free);
b->tvheap->free = toff + n->tvheap->free;
- /* flush double-elimination hash table */
- memset(b->tvheap->base, 0, GDK_STRHASHSIZE);
+ if (toff > 0) {
+ /* flush double-elimination
+ * hash table */
+ memset(b->tvheap->base, 0,
+ GDK_STRHASHSIZE);
+ }
}
}
if (toff != ~(size_t) 0) {
@@ -195,34 +199,6 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
goto bunins_failed;
}
}
- switch (b->twidth) {
- case 1:
- b->ttype = TYPE_bte;
- tp = &tbv;
- break;
- case 2:
- b->ttype = TYPE_sht;
- tp = &tsv;
- break;
-#if SIZEOF_VAR_T == 8
- case 4:
- b->ttype = TYPE_int;
- tp = &tiv;
- break;
- case 8:
- b->ttype = TYPE_lng;
- tp = &v;
- break;
-#else
- case 4:
- b->ttype = TYPE_int;
- tp = &v;
- break;
-#endif
- default:
- assert(0);
- }
- b->tvarsized = 0;
}
} else if (unshare_string_heap(b) != GDK_SUCCEED)
return GDK_FAIL;
@@ -250,6 +226,34 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
#endif
const var_t *restrict tvp = (const var_t *) Tloc(n, 0);
+ switch (b->twidth) {
+ case 1:
+ b->ttype = TYPE_bte;
+ tp = &tbv;
+ break;
+ case 2:
+ b->ttype = TYPE_sht;
+ tp = &tsv;
+ break;
+#if SIZEOF_VAR_T == 8
+ case 4:
+ b->ttype = TYPE_int;
+ tp = &tiv;
+ break;
+ case 8:
+ b->ttype = TYPE_lng;
+ tp = &v;
+ break;
+#else
+ case 4:
+ b->ttype = TYPE_int;
+ tp = &v;
+ break;
+#endif
+ default:
+ assert(0);
+ }
+ b->tvarsized = 0;
for (;;) {
if (cand) {
if (cand == candend)
@@ -299,6 +303,8 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
}
bunfastapp(b, tp);
}
+ b->tvarsized = 1;
+ b->ttype = TYPE_str;
} else if (b->tvheap->free < n->tvheap->free / 2 ||
GDK_ELIMDOUBLES(b->tvheap)) {
/* if b's string heap is much smaller than n's string
@@ -394,8 +400,6 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
r++;
}
}
- b->tvarsized = 1;
- b->ttype = TYPE_str;
return GDK_SUCCEED;
bunins_failed:
b->tvarsized = 1;
@@ -562,7 +566,7 @@ BATappend(BAT *b, BAT *n, BAT *s, bit fo
b->tnokey[0] = b->tnokey[1] = 0;
}
} else {
- BUN last = BUNlast(b) - 1;
+ BUN last = r - 1;
BATiter ni = bat_iterator(n);
BATiter bi = bat_iterator(b);
int xx = ATOMcmp(b->ttype, BUNtail(ni, start), BUNtail(bi,
last));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list