Changeset: efc00e7b6e61 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/efc00e7b6e61
Modified Files:
        gdk/gdk_calc_convert.c
        gdk/gdk_hash.c
Branch: Dec2023
Log Message:

Move looking up function pointer out of the inner loop.


diffs (78 lines):

diff --git a/gdk/gdk_calc_convert.c b/gdk/gdk_calc_convert.c
--- a/gdk/gdk_calc_convert.c
+++ b/gdk/gdk_calc_convert.c
@@ -865,6 +865,7 @@ convert_str_fix(BATiter *bi, int tp, voi
                return 0;
        }
 
+       int (*atomcmp)(const void *, const void *) = ATOMcompare(tp);
        TIMEOUT_LOOP(ci->ncand, timeoffset) {
                oid x = canditer_next(ci) - candoff;
                const char *s = BUNtvar(*bi, x);
@@ -878,7 +879,7 @@ convert_str_fix(BATiter *bi, int tp, voi
                                goto conversion_failed;
                        }
                        assert(len == ATOMsize(tp));
-                       if (ATOMcmp(tp, dst, nil) == 0)
+                       if (atomcmp(dst, nil) == 0)
                                nils++;
                }
                dst = (void *) ((char *) dst + len);
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -899,7 +899,8 @@ BAThash_impl(BAT *restrict b, struct can
                case TYPE_uuid:
                        starthash(uuid);
                        break;
-               default:
+               default: {
+                       int (*atomcmp)(const void *, const void *) = 
ATOMcompare(h->type);
                        TIMEOUT_LOOP(p, timeoffset) {
                                const void *restrict v = BUNtail(bi, o - 
b->hseqbase);
                                c = hash_any(h, v);
@@ -913,8 +914,7 @@ BAThash_impl(BAT *restrict b, struct can
                                        for (hb = hget;
                                             hb != BUN_NONE;
                                             hb = HASHgetlink(h, hb)) {
-                                               if (ATOMcmp(h->type,
-                                                           v,
+                                               if (atomcmp(v,
                                                            BUNtail(bi, hb)) == 
0)
                                                        break;
                                        }
@@ -928,6 +928,7 @@ BAThash_impl(BAT *restrict b, struct can
                                      GOTO_LABEL_TIMEOUT_HANDLER(bailout));
                        break;
                }
+               }
                TRC_DEBUG_IF(ACCELERATOR) if (p < cnt1)
                        TRC_DEBUG_ENDIF(ACCELERATOR,
                                        "%s: abort starthash with "
@@ -975,7 +976,8 @@ BAThash_impl(BAT *restrict b, struct can
        case TYPE_uuid:
                finishhash(uuid);
                break;
-       default:
+       default: {
+               int (*atomcmp)(const void *, const void *) = 
ATOMcompare(h->type);
                TIMEOUT_LOOP(ci->ncand - p, timeoffset) {
                        const void *restrict v = BUNtail(bi, o - b->hseqbase);
                        c = hash_any(h, v);
@@ -985,7 +987,7 @@ BAThash_impl(BAT *restrict b, struct can
                                for (hb = hget;
                                     hb != BUN_NONE;
                                     hb = HASHgetlink(h, hb)) {
-                                       if (ATOMcmp(h->type, v, BUNtail(bi, 
hb)) == 0)
+                                       if (atomcmp(v, BUNtail(bi, hb)) == 0)
                                                break;
                                }
                                h->nunique += hb == BUN_NONE;
@@ -999,6 +1001,7 @@ BAThash_impl(BAT *restrict b, struct can
                              GOTO_LABEL_TIMEOUT_HANDLER(bailout));
                break;
        }
+       }
        bat_iterator_end(&bi);
        /* if the number of unique values is equal to the bat count,
         * all values are necessarily distinct */
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to