Changeset: b0f51c763c66 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b0f51c763c66
Modified Files:
        monetdb5/optimizer/opt_wrapper.c
Branch: default
Log Message:

No need to use a hash for a 30 entry table.


diffs (65 lines):

diff --git a/monetdb5/optimizer/opt_wrapper.c b/monetdb5/optimizer/opt_wrapper.c
--- a/monetdb5/optimizer/opt_wrapper.c
+++ b/monetdb5/optimizer/opt_wrapper.c
@@ -56,7 +56,7 @@
 // keep the optimizer list sorted
 static struct {
        str nme;
-       str (*fcn)();
+       str (*fcn)(Client, MalBlkPtr, MalStkPtr, InstrPtr);
        int calls;
        lng timing;
 } codes[] = {
@@ -92,35 +92,19 @@ static struct {
        {"reorder", &OPTreorderImplementation,0,0},
        {0,0,0,0}
 };
-static int codehash[256];
 static MT_Lock codeslock = MT_LOCK_INITIALIZER(codeslock);
 
-static
-void fillcodehash(void)
+str
+OPTwrapper(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
 {
-       int i, idx;
-
-       for( i=0;  i< 256; i++)
-               codehash[i] = -1;
-       for (i=0; codes[i].nme; i++){
-               idx = (int) codes[i].nme[0];
-               if( codehash[idx] == -1 ){
-                       codehash[idx] = i;
-               }
-       }
-}
-
-str OPTwrapper (Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p){
-       str modnme = "(NONE)";
-       const char *fcnnme = "(NONE)";
+       str modnme = "optimizer";
+       const char *fcnnme;
        Symbol s= NULL;
        int i;
        str msg = MAL_SUCCEED;
        lng clk;
 
        // no optimizer starts with a null byte, initialization sets a zero
-       if( codehash[0] != -1 || codehash[0] == 0)
-               fillcodehash();
        if (cntxt->mode == FINISHCLIENT)
                throw(MAL, "optimizer", SQLSTATE(42000) "prematurely stopped 
client");
 
@@ -160,9 +144,9 @@ str OPTwrapper (Client cntxt, MalBlkPtr 
 
        clk = GDKusec();
        const char *id = getFunctionId(p);
-       for (i=codehash[(unsigned char) *id]; codes[i].nme; i++){
-               if (codes[i].nme[0] == *id && strcmp(codes[i].nme, 
getFunctionId(p)) == 0){
-                       msg = (str)(*(codes[i].fcn))(cntxt, mb, stk, p);
+       for (i = 0; codes[i].nme != NULL; i++) {
+               if (strcmp(codes[i].nme, id) == 0) {
+                       msg = (str)(*codes[i].fcn)(cntxt, mb, stk, p);
                        clk = GDKusec() - clk;
                        MT_lock_set(&codeslock);
                        codes[i].timing += clk;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to