diff OrthancServer/LuaScripting.cpp @ 2638:25ae209dcea9 jobs

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:58:07 +0200
parents 1232922c8793
children c691fcf66071
line wrap: on
line diff
--- a/OrthancServer/LuaScripting.cpp	Mon May 28 10:52:18 2018 +0200
+++ b/OrthancServer/LuaScripting.cpp	Mon May 28 10:58:07 2018 +0200
@@ -154,6 +154,16 @@
           throw OrthancException(ErrorCode_InternalError);
       }
 
+      {
+        // Avoid unnecessary calls to the database if there's no Lua callback
+        LuaScripting::Lock lock(that);
+
+        if (!lock.GetLua().IsExistingFunction(name))
+        {
+          return;
+        }
+      }
+      
       Json::Value tags, metadata;
       if (that.context_.GetIndex().LookupResource(tags, change_.GetPublicId(), change_.GetResourceType()) &&
           that.context_.GetIndex().GetMetadata(metadata, change_.GetPublicId()))