Slight performance tweaks to mapping creation

This commit is contained in:
Matt Nadareski
2025-01-13 21:57:08 -05:00
parent c8496d0d7a
commit ccbb0dc04e

View File

@@ -120,11 +120,17 @@ namespace SabreTools.DatFiles
if (machineName == null || machineDesc == null) if (machineName == null || machineDesc == null)
continue; continue;
// Adjust the description
machineDesc = machineDesc.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
if (machineName == machineDesc)
continue;
// If the key mapping doesn't exist, add it // If the key mapping doesn't exist, add it
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
mapping.TryAdd(machineName, machineDesc.Replace('/', '_').Replace("\"", "''").Replace(":", " -")); mapping.TryAdd(machineName, machineDesc);
#else #else
mapping[machineName] = machineDesc.Replace('/', '_').Replace("\"", "''").Replace(":", " -"); if (!mapping.ContainsKey(machineName))
mapping[machineName] = machineDesc;
#endif #endif
} }
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
@@ -155,8 +161,14 @@ namespace SabreTools.DatFiles
if (machineName == null || machineDesc == null) if (machineName == null || machineDesc == null)
continue; continue;
// Adjust the description
machineDesc = machineDesc.Replace('/', '_').Replace("\"", "''").Replace(":", " -");
if (machineName == machineDesc)
continue;
// If the key mapping doesn't exist, add it // If the key mapping doesn't exist, add it
mapping[machineName] = machineDesc.Replace('/', '_').Replace("\"", "''").Replace(":", " -"); if (!mapping.ContainsKey(machineName))
mapping[machineName] = machineDesc;
} }
return mapping; return mapping;