Changeset: a9953dffd9e9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a9953dffd9e9
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_atoms.c
gdk/gdk_atoms.h
gdk/gdk_bat.c
Branch: default
Log Message:
Cleanup.
- Removed a bunch of unused macros.
- ATOMcmp is now a macro that calls the atom's compare function directly.
diffs (142 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -10,7 +10,6 @@ void ALIGNsetH(BAT *b1, BAT *b2);
void ALIGNsetT(BAT *b1, BAT *b2);
int ALIGNsynced(BAT *b1, BAT *b2);
int ATOMallocate(const char *nme);
-int ATOMcmp(int id, const void *v_1, const void *v_2);
ptr ATOMdup(int id, const void *val);
bte ATOMelmshift(int sz);
char *ATOMformat(int id, const void *val);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1791,7 +1791,7 @@ gdk_export BAT *BBPquickdesc(bat b, int
* value. `val' is a direct pointer to the atom value. Its return
* value should be an hash_t between 0 and 'mask'.
*
- * @item The @emph{ATOMcmp()} operation computes two atomic
+ * @item The @emph{ATOMcmp()} operation compares two atomic
* values. Its parameters are pointers to atomic values.
*
* @item The @emph{ATOMlen()} operation computes the byte length for a
@@ -1892,7 +1892,6 @@ gdk_export int ATOMindex(const char *nme
gdk_export str ATOMname(int id);
gdk_export size_t ATOMlen(int id, const void *v);
gdk_export ptr ATOMnil(int id);
-gdk_export int ATOMcmp(int id, const void *v_1, const void *v_2);
gdk_export int ATOMprint(int id, const void *val, stream *fd);
gdk_export char *ATOMformat(int id, const void *val);
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -282,31 +282,6 @@ ATOMheap(int t, Heap *hp, size_t cap)
return GDK_SUCCEED;
}
-int
-ATOMcmp(int t, const void *l, const void *r)
-{
- switch (ATOMbasetype(t)) {
- case TYPE_bte:
- return simple_CMP(l, r, bte);
- case TYPE_sht:
- return simple_CMP(l, r, sht);
- case TYPE_int:
- return simple_CMP(l, r, int);
- case TYPE_flt:
- return simple_CMP(l, r, flt);
- case TYPE_lng:
- return simple_CMP(l, r, lng);
-#ifdef HAVE_HGE
- case TYPE_hge:
- return simple_CMP(l, r, hge);
-#endif
- case TYPE_dbl:
- return simple_CMP(l, r, dbl);
- default:
- return (l == r) ? 0 : atom_CMP(l, r, t);
- }
-}
-
/*
* Atom print avoids coercion to strings for built-in types.
* The comparison against the NULL value is hard coded for speed.
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -18,22 +18,8 @@
* code in one CPP macro we use the following #defines for comparing
* atoms:
*/
-#define simple_CMP(x,y,tpe) (simple_GT(x,y,tpe) - simple_LT(x,y,tpe))
+#define simple_CMP(x,y,tpe) (((*(const tpe*) (x)) > (*(const tpe*) (y))) -
((*(const tpe*) (x)) < (*(const tpe*) (y))))
#define simple_EQ(x,y,tpe) ((*(const tpe*) (x)) == (*(const tpe*) (y)))
-#define simple_NE(x,y,tpe,nl) ((*(const tpe*)(y)) != nl && (*(const tpe*)
(x)) != (*(const tpe*) (y)))
-#define simple_LT(x,y,tpe) ((*(const tpe*) (x)) < (*(const tpe*) (y)))
-#define simple_GT(x,y,tpe) ((*(const tpe*) (x)) > (*(const tpe*) (y)))
-#define simple_LE(x,y,tpe) ((*(const tpe*) (x)) <= (*(const tpe*) (y)))
-#define simple_GE(x,y,tpe) ((*(const tpe*) (x)) >= (*(const tpe*) (y)))
-#define atom_CMP(x,y,id) (*ATOMcompare(id))(x,y)
-#define atom_EQ(x,y,id) ((*ATOMcompare(id))(x,y) == 0)
-#define atom_NE(x,y,id,nl) ((*ATOMcompare(id))(y,ATOMnilptr(id)) != 0 &&
(*ATOMcompare(id))(x,y) != 0)
-#define atom_LT(x,y,id) ((*ATOMcompare(id))(x,y) < 0)
-#define atom_GT(x,y,id) ((*ATOMcompare(id))(x,y) > 0)
-#define atom_LE(x,y,id) ((*ATOMcompare(id))(x,y) <= 0)
-#define atom_GE(x,y,id) ((*ATOMcompare(id))(x,y) >= 0)
-#define simple_HASH(v,tpe,dst) ((dst) *(const tpe *) (v))
-#define atom_HASH(v,id,dst) ((dst) ATOMhash(id, v))
/*
* @- maximum atomic string lengths
@@ -188,6 +174,7 @@ gdk_export const ptr ptr_nil;
#define ATOMfromstr(t,s,l,src) BATatoms[t].atomFromStr(src,l,s)
#define ATOMnilptr(t) BATatoms[t].atomNull
#define ATOMcompare(t) BATatoms[t].atomCmp
+#define ATOMcmp(t,l,r) ((*ATOMcompare(t))(l, r))
#define ATOMhash(t,src) BATatoms[t].atomHash(src)
#define ATOMdel(t,hp,src) do if (BATatoms[t].atomDel)
BATatoms[t].atomDel(hp,src); while (0)
#define ATOMvarsized(t) (BATatoms[t].atomPut != NULL)
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -910,7 +910,7 @@ static void
setcolprops(BAT *b, const void *x)
{
int isnil = b->ttype != TYPE_void &&
- atom_CMP(x, ATOMnilptr(b->ttype), b->ttype) == 0;
+ ATOMcmp(b->ttype, x, ATOMnilptr(b->ttype)) == 0;
BATiter bi;
BUN pos;
const void *prv;
@@ -965,7 +965,7 @@ setcolprops(BAT *b, const void *x)
bi = bat_iterator(b);
pos = BUNlast(b);
prv = BUNtail(bi, pos - 1);
- cmp = atom_CMP(prv, x, b->ttype);
+ cmp = ATOMcmp(b->ttype, prv, x);
if (!b->tunique && /* assume outside check if tunique */
b->tkey &&
@@ -1152,8 +1152,8 @@ BUNinplace(BAT *b, BUN p, const void *t,
ALIGNinp(b, "BUNinplace", force, GDK_FAIL); /* zap alignment info */
if (b->tnil &&
- atom_CMP(BUNtail(bi, p), ATOMnilptr(b->ttype), b->ttype) == 0 &&
- atom_CMP(t, ATOMnilptr(b->ttype), b->ttype) != 0) {
+ ATOMcmp(b->ttype, BUNtail(bi, p), ATOMnilptr(b->ttype)) == 0 &&
+ ATOMcmp(b->ttype, t, ATOMnilptr(b->ttype)) != 0) {
/* if old value is nil and new value isn't, we're not
* sure anymore about the nil property, so we must
* clear it */
@@ -1210,7 +1210,7 @@ BUNinplace(BAT *b, BUN p, const void *t,
} else if (!b->tkey && (b->tnokey[0] == p || b->tnokey[1] == p))
b->tnokey[0] = b->tnokey[1] = 0;
if (b->tnonil)
- b->tnonil = t && atom_CMP(t, ATOMnilptr(b->ttype), b->ttype) !=
0;
+ b->tnonil = t && ATOMcmp(b->ttype, t, ATOMnilptr(b->ttype)) !=
0;
b->theap.dirty = TRUE;
if (b->tvheap)
b->tvheap->dirty = TRUE;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list