Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize operations on dictionaries, fix small issue #420

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/Client/Patches/TimestampFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public static void FixPawn(Pawn p, Map oldMap, Map newMap)

public static void ProcessExposable(IExposable exposable)
{
if (timestampFields.ContainsKey(exposable.GetType()))
foreach (var del in timestampFields[exposable.GetType()])
if (timestampFields.TryGetValue(exposable.GetType(), out var fieldGetters))
foreach (var del in fieldGetters)
del(exposable) += currentOffset!.Value;
}
}
Expand Down
4 changes: 1 addition & 3 deletions Source/Client/UI/Layouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ public static bool BeginArea(int windowId, Rect rect, float spacing = 10f)
PushGroup(new El { rect = rect.AtZero(), spacing = spacing });

// Add to linked list
if (!firstTopLevel.ContainsKey(windowId))
firstTopLevel[windowId] = currentGroup;
else
if (!firstTopLevel.TryAdd(windowId, currentGroup))
currentTopLevel!.nextTopLevel = currentGroup;

// Set current list pointer
Expand Down
7 changes: 2 additions & 5 deletions Source/Client/Util/TypeCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ internal static void CacheTypeByName()
{
foreach (var type in GenTypes.AllTypes)
{
if (!typeByName.ContainsKey(type.Name))
typeByName[type.Name] = type;

if (!typeByFullName.ContainsKey(type.Name))
typeByFullName[type.FullName] = type;
typeByName.TryAdd(type.Name, type);
typeByFullName.TryAdd(type.FullName, type);
}
}

Expand Down
Loading