Reduce the number of steps

This commit is contained in:
Matt Nadareski
2016-04-29 11:49:23 -07:00
parent 797a2245b3
commit 842ab5f39d
2 changed files with 11 additions and 7 deletions

View File

@@ -151,21 +151,23 @@ namespace SabreTools.Helper
{
// Get all values in the dictionary and write out
List<RomData> sortable = new List<RomData>();
List<string> keys = dict.Keys.ToList();
foreach (string key in keys)
long count = 0;
foreach (List<RomData> roms in dict.Values)
{
if (merge)
{
sortable.Add(dict[key][0]);
dict.Remove(key);
sortable.Add(roms[0]);
count++;
}
else
{
sortable.AddRange(dict[key]);
dict.Remove(key);
sortable.AddRange(roms);
count += roms.Count;
}
}
logger.Log("The total number of items added for output is " + count);
// Sort the new list
RomManipulation.Sort(sortable, true);

View File

@@ -604,7 +604,8 @@ namespace SabreTools.Helper
/// </summary>
/// <param name="roms">List of RomData objects representing the roms to be sorted</param>
/// <param name="norename">True if files are not renamed, false otherwise</param>
public static void Sort(List<RomData> roms, bool norename)
/// <returns>True if it sorted correctly, false otherwise</returns>
public static bool Sort(List<RomData> roms, bool norename)
{
roms.Sort(delegate (RomData x, RomData y)
{
@@ -622,6 +623,7 @@ namespace SabreTools.Helper
}
return (norename ? String.Compare(x.Game, y.Game) : x.SystemID - y.SystemID);
});
return true;
}
/// <summary>