Use StringBuilder instead of manually appending strings in FieldSaver

This commit is contained in:
abcdefg30
2023-10-30 16:13:00 +01:00
committed by Gustas
parent 3f0159cd89
commit 48a2a75211

View File

@@ -15,6 +15,7 @@ using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using OpenRA.Primitives; using OpenRA.Primitives;
namespace OpenRA namespace OpenRA
@@ -84,7 +85,7 @@ namespace OpenRA
// This is only for documentation generation // This is only for documentation generation
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary<,>)) if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary<,>))
{ {
var result = ""; var result = new StringBuilder();
var dict = (System.Collections.IDictionary)v; var dict = (System.Collections.IDictionary)v;
foreach (var kvp in dict) foreach (var kvp in dict)
{ {
@@ -94,10 +95,10 @@ namespace OpenRA
var formattedKey = FormatValue(key); var formattedKey = FormatValue(key);
var formattedValue = FormatValue(value); var formattedValue = FormatValue(value);
result += $"{formattedKey}: {formattedValue}{Environment.NewLine}"; result.Append($"{formattedKey}: {formattedValue}{Environment.NewLine}");
} }
return result; return result.ToString();
} }
if (v is DateTime d) if (v is DateTime d)