Skip to content

Commit 77f8053

Browse files
SugoiDevveblush
authored andcommitted
Fixes #24 (sluggish CompilerSettings window) (#25)
This fixes #24. Added caching for the `process` object and the `version` string.
1 parent f0b8124 commit 77f8053

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

core/UnityPackage/Assets/Editor/CompilerSettings.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public struct IncrementalCompilerSettings
5858
private DateTime _icsLastWriteTime;
5959
private IncrementalCompilerSettings _ics;
6060

61+
private string _version;
62+
private Process icProcess;
63+
6164
[MenuItem("Assets/Open C# Compiler Settings...")]
6265
public static void ShowWindow()
6366
{
@@ -161,8 +164,13 @@ private void SaveUniversalCompilerSettings()
161164

162165
private string GetUniversalCompilerVersion()
163166
{
167+
if (_version != null) {
168+
return _version;
169+
}
170+
164171
var assemblyName = AssemblyName.GetAssemblyName("./Compiler/UniversalCompiler.exe");
165-
return assemblyName != null ? assemblyName.Version.ToString() : "";
172+
_version = assemblyName != null ? assemblyName.Version.ToString() : "";
173+
return _version;
166174
}
167175

168176
private void ShowUniversalCompilerClientLog()
@@ -326,14 +334,19 @@ private string GetIncrementalCompilerVersion()
326334

327335
private Process GetIncrementalCompilerProcess()
328336
{
337+
if (icProcess != null) {
338+
return icProcess;
339+
}
340+
329341
try
330342
{
331343
var processes = Process.GetProcessesByName("IncrementalCompiler");
332344
foreach (var process in processes)
333345
{
334346
var dir = Directory.GetCurrentDirectory();
335347
if (process.MainModule.FileName.StartsWith(dir))
336-
return process;
348+
icProcess = process;
349+
return icProcess;
337350
}
338351
return null;
339352
}

0 commit comments

Comments
 (0)