Do not access dictionary with index

This commit is contained in:
Matt Nadareski
2026-04-17 09:14:39 -04:00
parent ecd4e7d1df
commit 25ab9acb57

View File

@@ -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