changeset 2637:5094369664f0

Avoid unnecessary calls to the database if there is no Lua callback
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 May 2018 10:54:59 +0200
parents 442e7ef5cc41
children 89b789366596
files OrthancServer/LuaScripting.cpp
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/LuaScripting.cpp	Fri May 25 18:54:11 2018 +0200
+++ b/OrthancServer/LuaScripting.cpp	Mon May 28 10:54:59 2018 +0200
@@ -468,7 +468,15 @@
         throw OrthancException(ErrorCode_InternalError);
     }
 
-
+    {
+      // Avoid unnecessary calls to the database if there's no Lua callback
+      boost::recursive_mutex::scoped_lock lock(mutex_);
+      if (!lua_.IsExistingFunction(name))
+      {
+        return;
+      }
+    }
+    
     Json::Value tags, metadata;
     if (context_.GetIndex().LookupResource(tags, change.GetPublicId(), change.GetResourceType()) &&
         context_.GetIndex().GetMetadata(metadata, change.GetPublicId()))