core: use lazy on-demand initialization for param_traceEnable
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Sun, 12 Jul 2020 11:53:46 +0000 (11:53 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Sun, 12 Jul 2020 11:53:46 +0000 (11:53 +0000)
modules/core/src/trace.cpp

index 4245ab2..c316737 100644 (file)
@@ -72,9 +72,13 @@ static int64 getTimestamp()
     return (int64)((t - g_zero_timestamp) * tick_to_ns);
 }
 
-// TODO lazy configuration flags
-static bool param_traceEnable = utils::getConfigurationParameterBool("OPENCV_TRACE", false);
+static bool getParameterTraceEnable()
+{
+    static bool param_traceEnable = utils::getConfigurationParameterBool("OPENCV_TRACE", false);
+    return param_traceEnable;
+}
 
+// TODO lazy configuration flags
 static int param_maxRegionDepthOpenCV = (int)utils::getConfigurationParameterSizeT("OPENCV_TRACE_DEPTH_OPENCV", 1);
 static int param_maxRegionChildrenOpenCV = (int)utils::getConfigurationParameterSizeT("OPENCV_TRACE_MAX_CHILDREN_OPENCV", 1000);
 static int param_maxRegionChildren = (int)utils::getConfigurationParameterSizeT("OPENCV_TRACE_MAX_CHILDREN", 10000);
@@ -841,7 +845,7 @@ TraceManager::TraceManager()
     CV_LOG("TraceManager ctor: " << (void*)this);
 
     CV_LOG("TraceManager configure()");
-    activated = param_traceEnable;
+    activated = getParameterTraceEnable();
 
     if (activated)
         trace_storage.reset(new SyncTraceStorage(std::string(param_traceLocation) + ".txt"));