Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit b8b6cc1

Browse files
committed
1.8.0.1
* Added some internal caching for Enum Names, should vastly improve speed when inspecting certain classes (worst case scenario I found went from over 50 seconds to less than 1 second). * ILRepack is now done as part of the build process, should simplify things if you are building the project yourself.
1 parent 912b1b8 commit b8b6cc1

File tree

6 files changed

+54
-24
lines changed

6 files changed

+54
-24
lines changed

src/CachedObjects/Object/CacheDictionary.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Threading;
45
using UnityEngine;
56
#if CPP
67
using UnhollowerBaseLib;
@@ -15,8 +16,8 @@ public class CacheDictionary : CacheObjectBase, IExpandHeight
1516

1617
public PageHelper Pages = new PageHelper();
1718

18-
private CacheObjectBase[] m_cachedKeys;
19-
private CacheObjectBase[] m_cachedValues;
19+
private CacheObjectBase[] m_cachedKeys = new CacheObjectBase[0];
20+
private CacheObjectBase[] m_cachedValues = new CacheObjectBase[0];
2021

2122
public Type TypeOfKeys
2223
{
@@ -119,6 +120,11 @@ public override void UpdateValue()
119120

120121
base.UpdateValue();
121122

123+
CacheEntries();
124+
}
125+
126+
public void CacheEntries()
127+
{
122128
// reset
123129
IDict = null;
124130

@@ -190,8 +196,6 @@ public override void DrawValue(Rect window, float width)
190196

191197
var whitespace = CalcWhitespace(window);
192198

193-
int count = m_cachedKeys.Length;
194-
195199
if (!IsExpanded)
196200
{
197201
if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
@@ -209,6 +213,8 @@ public override void DrawValue(Rect window, float width)
209213

210214
var negativeWhitespace = window.width - (whitespace + 100f);
211215

216+
int count = m_cachedKeys.Length;
217+
212218
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
213219
string btnLabel = $"[{count}] <color=#2df7b2>Dictionary<{TypeOfKeys.FullName}, {TypeOfValues.FullName}></color>";
214220
if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) }))
@@ -260,21 +266,27 @@ public override void DrawValue(Rect window, float width)
260266

261267
//GUIUnstrip.Space(whitespace);
262268

263-
if (key == null || val == null)
269+
if (key == null && val == null)
264270
{
265271
GUILayout.Label($"[{i}] <i><color=grey>(null)</color></i>", new GUILayoutOption[0]);
266272
}
267273
else
268274
{
269275
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
270-
GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) });
276+
GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(40) });
271277

272278
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
273279
GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) });
274-
key.DrawValue(window, (window.width / 2) - 80f);
280+
if (key != null)
281+
key.DrawValue(window, (window.width / 2) - 80f);
282+
else
283+
GUILayout.Label("<i>null</i>", new GUILayoutOption[0]);
275284

276285
GUILayout.Label("Value:", new GUILayoutOption[] { GUILayout.Width(40) });
277-
val.DrawValue(window, (window.width / 2) - 80f);
286+
if (Value != null)
287+
val.DrawValue(window, (window.width / 2) - 80f);
288+
else
289+
GUILayout.Label("<i>null</i>", new GUILayoutOption[0]);
278290
}
279291

280292
}

src/CachedObjects/Object/CacheList.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Threading;
45
using System.Reflection;
56
using UnityEngine;
67

@@ -13,7 +14,7 @@ public class CacheList : CacheObjectBase, IExpandHeight
1314

1415
public PageHelper Pages = new PageHelper();
1516

16-
private CacheObjectBase[] m_cachedEntries;
17+
private CacheObjectBase[] m_cachedEntries = new CacheObjectBase[0];
1718

1819
// Type of Entries in the Array
1920
public Type EntryType
@@ -218,6 +219,11 @@ public override void UpdateValue()
218219
return;
219220
}
220221

222+
CacheEntries();
223+
}
224+
225+
public void CacheEntries()
226+
{
221227
var enumerator = Enumerable.GetEnumerator();
222228
if (enumerator == null)
223229
{
@@ -276,8 +282,6 @@ public override void DrawValue(Rect window, float width)
276282

277283
var whitespace = CalcWhitespace(window);
278284

279-
int count = m_cachedEntries.Length;
280-
281285
if (!IsExpanded)
282286
{
283287
if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
@@ -295,6 +299,8 @@ public override void DrawValue(Rect window, float width)
295299

296300
var negativeWhitespace = window.width - (whitespace + 100f);
297301

302+
int count = m_cachedEntries.Length;
303+
298304
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
299305
string btnLabel = $"[{count}] <color=#2df7b2>{EntryType.FullName}</color>";
300306
if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) }))

src/CachedObjects/Struct/CacheEnum.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace Explorer
99
{
1010
public class CacheEnum : CacheObjectBase
1111
{
12+
internal static Dictionary<Type, string[]> EnumNamesInternalCache = new Dictionary<Type, string[]>();
13+
1214
// public Type EnumType;
1315
public string[] EnumNames = new string[0];
1416

@@ -20,24 +22,34 @@ public override void Init()
2022
}
2123

2224
if (ValueType != null)
25+
{
26+
GetNames();
27+
}
28+
else
29+
{
30+
ReflectionException = "Unknown, could not get Enum names.";
31+
}
32+
}
33+
34+
internal void GetNames()
35+
{
36+
if (!EnumNamesInternalCache.ContainsKey(ValueType))
2337
{
2438
// using GetValues not GetNames, to catch instances of weird enums (eg CameraClearFlags)
2539
var values = Enum.GetValues(ValueType);
2640

27-
var list = new List<string>();
41+
var set = new HashSet<string>();
2842
foreach (var value in values)
2943
{
3044
var v = value.ToString();
31-
if (list.Contains(v)) continue;
32-
list.Add(v);
45+
if (set.Contains(v)) continue;
46+
set.Add(v);
3347
}
3448

35-
EnumNames = list.ToArray();
36-
}
37-
else
38-
{
39-
ReflectionException = "Unknown, could not get Enum names.";
49+
EnumNamesInternalCache.Add(ValueType, set.ToArray());
4050
}
51+
52+
EnumNames = EnumNamesInternalCache[ValueType];
4153
}
4254

4355
public override void DrawValue(Rect window, float width)

src/Explorer.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
2929
<MLCppGameFolder>D:\Steam\steamapps\common\Hellpoint</MLCppGameFolder>
3030
<!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. -->
31-
<MLMonoGameFolder>D:\Steam\steamapps\common\Outward_Mono</MLMonoGameFolder>
31+
<MLMonoGameFolder>D:\Steam\steamapps\common\Outward</MLMonoGameFolder>
3232
<!-- Set this to the BepInEx Il2Cpp Game folder, without the ending '\' character. -->
33-
<BIECppGameFolder>D:\Steam\steamapps\common\Outward</BIECppGameFolder>
33+
<BIECppGameFolder>D:\Steam\steamapps\common\Outward_Il2Cpp</BIECppGameFolder>
3434
<!-- Set this to the BepInEx Mono Game folder, without the ending '\' character. -->
35-
<BIEMonoGameFolder>D:\Steam\steamapps\common\Outward_Mono</BIEMonoGameFolder>
35+
<BIEMonoGameFolder>D:\Steam\steamapps\common\Outward</BIEMonoGameFolder>
3636
<NuGetPackageImportStamp>
3737
</NuGetPackageImportStamp>
3838
</PropertyGroup>

src/Menu/ResizeDrag.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static Rect ResizeWindow(Rect _rect, int ID)
3232
#if ML
3333
GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) });
3434
#else
35-
GUILayout.Button(gcDrag.ToString(), new GUILayoutOption[] { GUILayout.Height(15) });
35+
GUILayout.Button("<-- Drag to resize -->", new GUILayoutOption[] { GUILayout.Height(15) });
3636
#endif
3737

3838
//var r = GUILayoutUtility.GetLastRect();

src/Menu/Windows/ReflectionWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void AppendParams(ParameterInfo[] _args)
202202
continue;
203203
}
204204

205-
// ExplorerCore.Log($"Trying to cache member {signature}...");
205+
//ExplorerCore.Log($"Trying to cache member {sig}...");
206206

207207
try
208208
{

0 commit comments

Comments
 (0)