-
Notifications
You must be signed in to change notification settings - Fork 671
Reduce allocations in Program.cs by hoisting deprecatedOptions array #10504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,13 @@ | |
| ILogger logger = new(SimpleConsoleLogger.Instance); | ||
| ProcessExitSource? processExitSource = default; | ||
| var unhandledError = "A critical error has occurred"; | ||
| Option<string>[] deprecatedOptions = | ||
| [ | ||
| BasicOptions.ConfigurationDirectory, | ||
| BasicOptions.DatabasePath, | ||
| BasicOptions.LoggerConfigurationSource, | ||
| BasicOptions.PluginsDirectory | ||
| ]; | ||
|
Comment on lines
+55
to
+61
|
||
|
|
||
| AppDomain.CurrentDomain.UnhandledException += (sender, e) => | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deprecatedOptions array should be marked as readonly to prevent accidental modification and to make it clear that this is an immutable collection. This is consistent with similar patterns throughout the codebase where static readonly or readonly is used for arrays that should not be modified. Additionally, the CheckForDeprecatedOptions method is called from ConfigureAsync (line 126) which is async and could potentially be called multiple times if the program is restarted, so readonly would ensure thread safety.