diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-15 01:54:01 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-15 01:54:01 -0400 |
commit | 048f41244f6b2c7f95ac5bf75be2b16f42b99169 (patch) | |
tree | 59f6937d63653a7cb3ec04fde9f76539429a7854 /src/SMAPI/Framework/ModRegistry.cs | |
parent | 3a4758dfa63f0f8e03166bffa15e16f7995499d7 (diff) | |
download | SMAPI-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/ModRegistry.cs')
-rw-r--r-- | src/SMAPI/Framework/ModRegistry.cs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/SMAPI/Framework/ModRegistry.cs b/src/SMAPI/Framework/ModRegistry.cs index 1ae5643f..1b0a076f 100644 --- a/src/SMAPI/Framework/ModRegistry.cs +++ b/src/SMAPI/Framework/ModRegistry.cs @@ -99,14 +99,10 @@ namespace StardewModdingAPI.Framework } /// <summary>Get the mod metadata from the closest assembly registered as a source of deprecation warnings.</summary> + /// <param name="frames">The call stack to analyze.</param> /// <returns>Returns the mod's metadata, or <c>null</c> if no registered assemblies were found.</returns> - public IModMetadata? GetFromStack() + public IModMetadata? GetFromStack(StackFrame[] frames) { - // get stack frames - StackTrace stack = new(); - StackFrame[] frames = stack.GetFrames(); - - // search stack for a source assembly foreach (StackFrame frame in frames) { IModMetadata? mod = this.GetFrom(frame); @@ -114,7 +110,6 @@ namespace StardewModdingAPI.Framework return mod; } - // no known assembly found return null; } } |