summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Content
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-15 01:54:01 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-15 01:54:01 -0400
commit048f41244f6b2c7f95ac5bf75be2b16f42b99169 (patch)
tree59f6937d63653a7cb3ec04fde9f76539429a7854 /src/SMAPI/Framework/Content
parent3a4758dfa63f0f8e03166bffa15e16f7995499d7 (diff)
downloadSMAPI-048f41244f6b2c7f95ac5bf75be2b16f42b99169.tar.gz
SMAPI-048f41244f6b2c7f95ac5bf75be2b16f42b99169.tar.bz2
SMAPI-048f41244f6b2c7f95ac5bf75be2b16f42b99169.zip
reduce performance impact of deprecation warnings
Creating a stack is *very* slow, so it should be avoided if possible until after the duplicate-warning check.
Diffstat (limited to 'src/SMAPI/Framework/Content')
-rw-r--r--src/SMAPI/Framework/Content/AssetInfo.cs4
-rw-r--r--src/SMAPI/Framework/Content/AssetInterceptorChange.cs10
2 files changed, 12 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/Content/AssetInfo.cs b/src/SMAPI/Framework/Content/AssetInfo.cs
index a4f0a408..773e3126 100644
--- a/src/SMAPI/Framework/Content/AssetInfo.cs
+++ b/src/SMAPI/Framework/Content/AssetInfo.cs
@@ -36,7 +36,7 @@ namespace StardewModdingAPI.Framework.Content
get
{
SCore.DeprecationManager.Warn(
- source: SCore.DeprecationManager.GetModFromStack(),
+ source: null,
nounPhrase: $"{nameof(IAssetInfo)}.{nameof(IAssetInfo.AssetName)}",
version: "3.14.0",
severity: DeprecationLevel.Notice,
@@ -76,7 +76,7 @@ namespace StardewModdingAPI.Framework.Content
public bool AssetNameEquals(string path)
{
SCore.DeprecationManager.Warn(
- source: SCore.DeprecationManager.GetModFromStack(),
+ source: null,
nounPhrase: $"{nameof(IAssetInfo)}.{nameof(IAssetInfo.AssetNameEquals)}",
version: "3.14.0",
severity: DeprecationLevel.Notice,
diff --git a/src/SMAPI/Framework/Content/AssetInterceptorChange.cs b/src/SMAPI/Framework/Content/AssetInterceptorChange.cs
index fc8199e8..f3d4f3f4 100644
--- a/src/SMAPI/Framework/Content/AssetInterceptorChange.cs
+++ b/src/SMAPI/Framework/Content/AssetInterceptorChange.cs
@@ -64,6 +64,7 @@ namespace StardewModdingAPI.Framework.Content
// check edit
if (this.Instance is IAssetEditor editor)
{
+ Context.HeuristicModsRunningCode.Push(this.Mod);
try
{
if (editor.CanEdit<TAsset>(asset))
@@ -73,11 +74,16 @@ namespace StardewModdingAPI.Framework.Content
{
this.Mod.LogAsMod($"Mod failed when checking whether it could edit asset '{asset.Name}'. Error details:\n{ex.GetLogSummary()}", LogLevel.Error);
}
+ finally
+ {
+ Context.HeuristicModsRunningCode.TryPop(out _);
+ }
}
// check load
if (this.Instance is IAssetLoader loader)
{
+ Context.HeuristicModsRunningCode.Push(this.Mod);
try
{
if (loader.CanLoad<TAsset>(asset))
@@ -87,6 +93,10 @@ namespace StardewModdingAPI.Framework.Content
{
this.Mod.LogAsMod($"Mod failed when checking whether it could load asset '{asset.Name}'. Error details:\n{ex.GetLogSummary()}", LogLevel.Error);
}
+ finally
+ {
+ Context.HeuristicModsRunningCode.TryPop(out _);
+ }
}
return false;