changeset 6706:688f0f78ddfc

further build optimization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 13 Apr 2026 18:29:35 +0200
parents 2c1b578ed9ba
children 595154a8b394 7757956d909e
files OrthancFramework/Sources/Logging.cpp OrthancFramework/Sources/Logging.h OrthancFramework/Sources/SQLite/Statement.cpp
diffstat 3 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/Logging.cpp	Mon Apr 13 17:52:49 2026 +0200
+++ b/OrthancFramework/Sources/Logging.cpp	Mon Apr 13 18:29:35 2026 +0200
@@ -912,12 +912,22 @@
     }
 
 
+    struct InternalLogger::PImpl
+    {
+      boost::mutex::scoped_lock  lock_;
+
+      PImpl() : lock_(loggingStreamsMutex_, boost::defer_lock_t())
+      {
+      }
+    };
+
+
     InternalLogger::InternalLogger(LogLevel level,
                                    LogCategory category,
                                    const char* pluginName,
                                    const char* file,
                                    int line) :
-      lock_(loggingStreamsMutex_, boost::defer_lock_t()),
+      pimpl_(new PImpl),
       level_(level),
       stream_(&nullStream_),  // By default, logging to "/dev/null" is simulated
       category_(category),
@@ -953,14 +963,14 @@
         {
           // We lock the global mutex. The mutex is locked until the
           // destructor is called: No change in the output can be done.
-          lock_.lock();
+          pimpl_->lock_.lock();
       
           if (loggingStreamsContext_.get() == NULL)
           {
             // Have you called Orthanc::Logging::InitializePluginContext()?
             fprintf(stderr, "ERROR: Trying to log a message after the finalization of the logging engine "
                     "(or did you forgot to initialize it?)\n");
-            lock_.unlock();
+            pimpl_->lock_.unlock();
             return;
           }
 
@@ -988,7 +998,7 @@
           {
             // The logging is disabled for this level, we can release
             // the global mutex.
-            lock_.unlock();
+            pimpl_->lock_.unlock();
           }
           else
           {
@@ -1064,8 +1074,10 @@
         {
           (*it)->HandleLog(level_, category_, pluginName_, file_, line_, messageStream_.str());
         }
+      }
 
-      }
+      assert(pimpl_ != NULL);
+      delete pimpl_;
     }
       
 
--- a/OrthancFramework/Sources/Logging.h	Mon Apr 13 17:52:49 2026 +0200
+++ b/OrthancFramework/Sources/Logging.h	Mon Apr 13 18:29:35 2026 +0200
@@ -267,7 +267,6 @@
      ORTHANC_ENABLE_LOGGING_STDIO == 0)
 
 #include <boost/noncopyable.hpp>
-#include <boost/thread/mutex.hpp>
 #include <sstream>
 
 namespace Orthanc
@@ -277,7 +276,9 @@
     class ORTHANC_PUBLIC InternalLogger : public boost::noncopyable
     {
     private:
-      boost::mutex::scoped_lock           lock_;
+      struct PImpl;
+      PImpl* pimpl_;  // This encapsulates a "boost::mutex::scoped_lock", which is a heavyweight structure
+
       LogLevel                            level_;
       std::ostream*                       stream_;
       LogCategory                         category_;
--- a/OrthancFramework/Sources/SQLite/Statement.cpp	Mon Apr 13 17:52:49 2026 +0200
+++ b/OrthancFramework/Sources/SQLite/Statement.cpp	Mon Apr 13 18:29:35 2026 +0200
@@ -45,6 +45,7 @@
 #include "Statement.h"
 #include "Connection.h"
 
+#include <cassert>
 #include <string.h>
 #include <stdio.h>
 #include <algorithm>