From 83bfd29af889631ed2f22e774d50d80aa1ceb198 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 25 May 2008 19:26:21 +0000 Subject: Thank you very much, Xantor for a patch that: Copying, reseting, dragging scripts cause unnecessary recompilation, slowing down the simulator and filling up the ScriptEngines directory with compiled .dll and misc. files. This patch keeps track of compiled assets since the last simulator restarts, and only recompiles new assets. (editing a script generates a new asset, so no problems there). --- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine') diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 55289d9..a328a58 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -26,6 +26,8 @@ */ using System; +using System.Reflection; +using log4net; using libsecondlife; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; @@ -43,6 +45,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } private Compiler.LSL.Compiler LSLCompiler; + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public override void Initialize() { @@ -70,10 +75,31 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine SceneObjectPart m_host = World.GetSceneObjectPart(localID); + // Xantor 20080525: I need assetID here to see if we already compiled this one previously + LLUUID assetID = LLUUID.Zero; + TaskInventoryItem taskInventoryItem = new TaskInventoryItem(); + if(m_host.TaskInventory.TryGetValue(itemID,out taskInventoryItem)) + assetID = taskInventoryItem.AssetID; + + try { - // Compile (We assume LSL) - CompiledScriptFile = LSLCompiler.PerformScriptCompile(Script); + // Xantor 20080525 see if we already compiled this script this session, stop incessant recompiling on + // scriptreset, spawning of objects with embedded scripts etc. + + if (scriptList.TryGetValue(assetID, out CompiledScriptFile)) + { + m_log.InfoFormat("[SCRIPT]: Found existing compile of assetID {0}: {1}", assetID, CompiledScriptFile); + } + else + { + // Compile (We assume LSL) + CompiledScriptFile = LSLCompiler.PerformScriptCompile(Script); + + // Xantor 20080525 Save compiled scriptfile for later use + m_log.InfoFormat("[SCRIPT]: Compiled assetID {0}: {1}", assetID, CompiledScriptFile); + scriptList.Add(assetID, CompiledScriptFile); + } //#if DEBUG //long before; -- cgit v1.1