[gjs: 1/9] wrapperutils: Really make debug methods no-ops if compiled out




commit 870387bd1367a487ce543d0d5dc23d2c76f1b894
Author: Philip Chimento <philip chimento gmail com>
Date:   Mon Nov 30 19:37:54 2020 -0800

    wrapperutils: Really make debug methods no-ops if compiled out
    
    The debug methods are supposed to be no-ops if verbose logging is not
    compiled in, but what was happening was that the jsid and JSString were
    being converted to UTF-8 because only the code inside gjs_debug_jsprop()
    is ifdef'd out if not built with verbose logging. So this was potentially
    slowing down performance.
    
    Instead use constexpr to make these calls only if verbose logging is
    compiled in.

 gi/wrapperutils.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gi/wrapperutils.h b/gi/wrapperutils.h
index 05b34499..df1e5c19 100644
--- a/gi/wrapperutils.h
+++ b/gi/wrapperutils.h
@@ -304,11 +304,13 @@ class GIWrapperBase {
             message, id);
     }
     void debug_jsprop(const char* message, jsid id, const void* obj) const {
-        debug_jsprop(message, gjs_debug_id(id).c_str(), obj);
+        if constexpr (GJS_VERBOSE_ENABLE_PROPS)
+            debug_jsprop(message, gjs_debug_id(id).c_str(), obj);
     }
     void debug_jsprop(const char* message, JSString* id,
                       const void* obj) const {
-        debug_jsprop(message, gjs_debug_string(id).c_str(), obj);
+        if constexpr (GJS_VERBOSE_ENABLE_PROPS)
+            debug_jsprop(message, gjs_debug_string(id).c_str(), obj);
     }
     static void debug_jsprop_static(const char* message GJS_USED_VERBOSE_PROPS,
                                     jsid id GJS_USED_VERBOSE_PROPS,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]