mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-22 06:45:11 +00:00
Do not access dictionary with index
This commit is contained in:
@@ -238,18 +238,6 @@ namespace SabreTools.Metadata.DatFiles
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a value from the table, returning success
|
||||
/// </summary>
|
||||
public bool Remove(long index)
|
||||
{
|
||||
#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
return _table.TryRemove(index, out var _);
|
||||
#else
|
||||
return _table.Remove(index);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all values that match a function
|
||||
/// </summary>
|
||||
@@ -261,8 +249,16 @@ namespace SabreTools.Metadata.DatFiles
|
||||
for (int i = 0; i < Indexes.Length; i++)
|
||||
#endif
|
||||
{
|
||||
if (func(_table[i]))
|
||||
Remove(i);
|
||||
var value = Get(i);
|
||||
if (value is null)
|
||||
#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
return;
|
||||
#else
|
||||
continue;
|
||||
#endif
|
||||
|
||||
if (func(value))
|
||||
TryRemove(i, out _);
|
||||
#if NET40_OR_GREATER || NETCOREAPP || NETSTANDARD2_0_OR_GREATER
|
||||
});
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user