[DatFile] Wrap intial bucketby in an if-statement

This commit is contained in:
Matt Nadareski
2017-10-05 15:22:55 -07:00
parent 95d6d9829b
commit 6d25997981

View File

@@ -30,18 +30,15 @@ namespace SabreTools.Library.Dats
/// <param name="norename">True if games should only be compared on game and file name, false if system and source are counted</param> /// <param name="norename">True if games should only be compared on game and file name, false if system and source are counted</param>
public void BucketBy(SortedBy bucketBy, DedupeType deduperoms, bool lower = true, bool norename = true) public void BucketBy(SortedBy bucketBy, DedupeType deduperoms, bool lower = true, bool norename = true)
{ {
// If we already have the right sorting, trust it
if (_sortedBy == bucketBy)
{
return;
}
// If we have a situation where there's no dictionary or no keys at all, we skip // If we have a situation where there's no dictionary or no keys at all, we skip
if (_items == null || _items.Count == 0) if (_items == null || _items.Count == 0)
{ {
return; return;
} }
// If the sorted type isn't the same, we want to sort the dictionary accordingly
if (_sortedBy != bucketBy)
{
// Set the sorted type // Set the sorted type
_sortedBy = bucketBy; _sortedBy = bucketBy;
@@ -52,8 +49,8 @@ namespace SabreTools.Library.Dats
Globals.Logger.User("Organizing roms by {0}" + (deduperoms != DedupeType.None ? " and merging" : ""), bucketBy); Globals.Logger.User("Organizing roms by {0}" + (deduperoms != DedupeType.None ? " and merging" : ""), bucketBy);
// First do the initial sort of all of the roms // First do the initial sort of all of the roms
List<string> keys = sortable.Keys.ToList(); List<string> oldkeys = sortable.Keys.ToList();
Parallel.ForEach(keys, Globals.ParallelOptions, key => Parallel.ForEach(oldkeys, Globals.ParallelOptions, key =>
{ {
List<DatItem> roms = sortable[key]; List<DatItem> roms = sortable[key];
@@ -134,9 +131,10 @@ namespace SabreTools.Library.Dats
Add(newkey, rom); Add(newkey, rom);
} }
}); });
}
// Now go through and sort all of the individual lists // Now go through and sort all of the individual lists
keys = Keys.ToList(); List<string> keys = Keys.ToList();
Parallel.ForEach(keys, Globals.ParallelOptions, key => Parallel.ForEach(keys, Globals.ParallelOptions, key =>
{ {
// Get the possibly unsorted list // Get the possibly unsorted list