mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Clean empty keys in a saner way
This commit is contained in:
@@ -1435,12 +1435,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
i--; // This make sure that the pointer stays on the correct since one was removed
|
i--; // This make sure that the pointer stays on the correct since one was removed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now remove the old key (if different than the current key)
|
|
||||||
if (!currentkey)
|
|
||||||
{
|
|
||||||
Remove(key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1472,6 +1466,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
AddRange(key, sortedlist);
|
AddRange(key, sortedlist);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now clean up all empty keys
|
||||||
|
CleanEmptyKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1558,6 +1555,21 @@ namespace SabreTools.Library.DatFiles
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean out all empty keys in the dictionary
|
||||||
|
/// </summary>
|
||||||
|
private void CleanEmptyKeys()
|
||||||
|
{
|
||||||
|
List<string> keys = Keys;
|
||||||
|
foreach(string key in keys)
|
||||||
|
{
|
||||||
|
if (this[key].Count == 0)
|
||||||
|
{
|
||||||
|
Remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|||||||
Reference in New Issue
Block a user