Changeset: 6016d3264798 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6016d3264798
Modified Files:
        gdk/gdk_tracer.c
        gdk/gdk_tracer.h
Branch: Oct2020
Log Message:

Use fewer comparisons by using the fact that trace levels are ordered.


diffs (44 lines):

diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -491,7 +491,7 @@ GDKtracer_log(const char *file, const ch
        if ((p = strchr(buffer, '\n')) != NULL)
                *p = '\0';
 
-       if (comp == GDK && (level == M_CRITICAL || level == M_ERROR)) {
+       if (comp == GDK && level <= M_ERROR) {
                /* append message to GDKerrbuf (if set) */
                char *buf = GDKerrbuf;
                if (buf) {
@@ -504,7 +504,7 @@ GDKtracer_log(const char *file, const ch
                }
        }
 
-       if (level == M_CRITICAL || level == M_ERROR || level == M_WARNING) {
+       if (level <= M_WARNING) {
                fprintf(stderr, "#%s%s%s: %s: %s%s%s%s\n",
                        add_ts ? ts : "",
                        add_ts ? ": " : "",
@@ -527,7 +527,7 @@ GDKtracer_log(const char *file, const ch
        // like mserver5 refusing to start due to allocated port
        // and the error is never reported to the user because it
        // is still in the buffer which it never gets flushed.
-       if (level == cur_flush_level || level == M_CRITICAL || level == M_ERROR)
+       if (level == cur_flush_level || level <= M_ERROR)
                fflush(active_tracer);
 }
 
diff --git a/gdk/gdk_tracer.h b/gdk/gdk_tracer.h
--- a/gdk/gdk_tracer.h
+++ b/gdk/gdk_tracer.h
@@ -140,9 +140,7 @@ gdk_export log_level_t lvl_per_component
 // ERROR or WARNING it is logged no matter the component. In any other
 // case the component is taken into account
 #define GDK_TRACER_TEST(LOG_LEVEL, COMP)       \
-       (LOG_LEVEL == M_CRITICAL ||             \
-        LOG_LEVEL == M_ERROR    ||             \
-        LOG_LEVEL == M_WARNING  ||             \
+       (LOG_LEVEL <= M_WARNING  ||             \
         lvl_per_component[COMP] >= LOG_LEVEL)
 
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to