From c09911e6a26693dc4f75809979054ff09e7b3bf1 Mon Sep 17 00:00:00 2001 From: SugoiDev Date: Fri, 10 Feb 2017 04:25:08 -0200 Subject: [PATCH] Fixes #24 (sluggish CompilerSettings window) This fixes #24. Added caching for the `process` object and the `version` string. --- .../Assets/Editor/CompilerSettings.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/core/UnityPackage/Assets/Editor/CompilerSettings.cs b/core/UnityPackage/Assets/Editor/CompilerSettings.cs index e788330..2b43f80 100644 --- a/core/UnityPackage/Assets/Editor/CompilerSettings.cs +++ b/core/UnityPackage/Assets/Editor/CompilerSettings.cs @@ -58,6 +58,9 @@ public struct IncrementalCompilerSettings private DateTime _icsLastWriteTime; private IncrementalCompilerSettings _ics; + private string _version; + private Process icProcess; + [MenuItem("Assets/Open C# Compiler Settings...")] public static void ShowWindow() { @@ -161,8 +164,13 @@ private void SaveUniversalCompilerSettings() private string GetUniversalCompilerVersion() { + if (_version != null) { + return _version; + } + var assemblyName = AssemblyName.GetAssemblyName("./Compiler/UniversalCompiler.exe"); - return assemblyName != null ? assemblyName.Version.ToString() : ""; + _version = assemblyName != null ? assemblyName.Version.ToString() : ""; + return _version; } private void ShowUniversalCompilerClientLog() @@ -326,6 +334,10 @@ private string GetIncrementalCompilerVersion() private Process GetIncrementalCompilerProcess() { + if (icProcess != null) { + return icProcess; + } + try { var processes = Process.GetProcessesByName("IncrementalCompiler"); @@ -333,7 +345,8 @@ private Process GetIncrementalCompilerProcess() { var dir = Directory.GetCurrentDirectory(); if (process.MainModule.FileName.StartsWith(dir)) - return process; + icProcess = process; + return icProcess; } return null; }