mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-04-24 23:30:07 +00:00
Clear empty keys as you go
This commit is contained in:
@@ -166,6 +166,9 @@ namespace BurnOutSharp
|
||||
}
|
||||
}
|
||||
|
||||
// Clear out any empty keys
|
||||
Utilities.ClearEmptyKeys(protections);
|
||||
|
||||
return protections;
|
||||
}
|
||||
|
||||
@@ -569,6 +572,9 @@ namespace BurnOutSharp
|
||||
#endregion
|
||||
}
|
||||
|
||||
// Clear out any empty keys
|
||||
Utilities.ClearEmptyKeys(protections);
|
||||
|
||||
return protections;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,31 @@ namespace BurnOutSharp
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove empty or null keys from a results dictionary
|
||||
/// </summary>
|
||||
/// <param name="original">Dictionary to clean</param>
|
||||
public static void ClearEmptyKeys(Dictionary<string, List<string>> original)
|
||||
{
|
||||
// If the dictionary is missing, we can't do anything
|
||||
if (original == null)
|
||||
return;
|
||||
|
||||
// Get a list of all of the keys
|
||||
var keys = original.Keys.ToList();
|
||||
|
||||
// Iterate and reset keys
|
||||
for (int i = 0; i < keys.Count; i++)
|
||||
{
|
||||
// Get the current key
|
||||
string key = keys[i];
|
||||
|
||||
// If the key is empty, remove it
|
||||
if (original[key] == null || !original[key].Any())
|
||||
original.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prepend a parent path from dictionary keys, if possible
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user