summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-06-02 01:28:04 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-06-10 00:04:26 -0400
commit62328e438487a55cb84ee09ef966092572b2252e (patch)
tree86b2fd5ee229ac51479bac79e875426bb1d73c58 /src
parent03897776e08cb0703c9763e3b5dcc81d85f277f9 (diff)
downloadSMAPI-62328e438487a55cb84ee09ef966092572b2252e.tar.gz
SMAPI-62328e438487a55cb84ee09ef966092572b2252e.tar.bz2
SMAPI-62328e438487a55cb84ee09ef966092572b2252e.zip
tweak new code, update release notes
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/Content/ContentCache.cs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/SMAPI/Framework/Content/ContentCache.cs b/src/SMAPI/Framework/Content/ContentCache.cs
index 959d4fb3..bf42812b 100644
--- a/src/SMAPI/Framework/Content/ContentCache.cs
+++ b/src/SMAPI/Framework/Content/ContentCache.cs
@@ -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;
}
}
}