Skip to content

Commit b88cdfd

Browse files
TiliSleepStealerjacobdufault
authored andcommitted
Small fix for faster TryIndirectTypeLookup (#107)
The function was doing really silly things if you had more than one assembly in the project. This removed over 10MB of allocations on our game.
1 parent 33f02b8 commit b88cdfd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Assets/FullSerializer/Source/Reflection/fsTypeCache.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ private static bool TryIndirectTypeLookup(string typeName, out Type type) {
9898
if (type != null) {
9999
return true;
100100
}
101+
++i;
102+
}
103+
104+
i = 0;
105+
// This code here is slow and is just here as a fallback
106+
while (i < _assembliesByIndex.Count) {
107+
Assembly assembly = _assembliesByIndex[i];
101108

102109
// private type or similar; go through the slow path and check every type's full
103110
// name
@@ -107,7 +114,6 @@ private static bool TryIndirectTypeLookup(string typeName, out Type type) {
107114
return true;
108115
}
109116
}
110-
111117
++i;
112118
}
113119

0 commit comments

Comments
 (0)