tweak new code, update release notes
This commit is contained in:
parent
03897776e0
commit
62328e4384
|
@ -6,6 +6,7 @@ See [release highlights](https://www.patreon.com/posts/66986798).
|
|||
|
||||
* For players:
|
||||
* Optimized mod image file loading.
|
||||
* Minor optimizations (thanks to Michael Kuklinski / Ameisen!).
|
||||
* For mod authors:
|
||||
* Added a new `IRawTextureData` asset type.
|
||||
_You can now load image files through `helper.ModContent` as `IRawTextureData` instead of `Texture2D`. This provides the image size and raw pixel data, which you can pass into other SMAPI APIs like `asset.AsImage().PatchImage`. This is much more efficient when you don't need a full `Texture2D` instance, since it bypasses the GPU operations needed to create one._
|
||||
|
|
|
@ -106,23 +106,19 @@ namespace StardewModdingAPI.Framework.Content
|
|||
/// <returns>Returns any removed keys.</returns>
|
||||
public IEnumerable<string> Remove(Func<string, object, bool> predicate, bool dispose)
|
||||
{
|
||||
List<string> removed = new List<string>();
|
||||
List<string> removed = new();
|
||||
foreach ((string key, object value) in this.Cache)
|
||||
{
|
||||
if (predicate(key, value))
|
||||
{
|
||||
removed.Add(key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string key in removed)
|
||||
{
|
||||
this.Remove(key, dispose);
|
||||
}
|
||||
|
||||
// If `removed` is empty, return an empty `Enumerable` instead so that `removed`
|
||||
// can be quickly collected in Gen0 instead of potentially living longer.
|
||||
return removed.Count == 0 ? Enumerable.Empty<string>() : removed;
|
||||
return removed.Count == 0
|
||||
? Enumerable.Empty<string>() // let GC collect the list in gen0 instead of potentially living longer
|
||||
: removed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue