misc: Prevent value change logging when the value is changed to the same thing it was before the value change.

This commit is contained in:
Evan Husted 2024-12-31 22:23:08 -06:00
parent 3fa714bb72
commit 732aafd3bb
2 changed files with 24 additions and 66 deletions

View file

@ -53,6 +53,17 @@ namespace Ryujinx.Common
{
public static void LogValueChange<T>(LogClass logClass, ReactiveEventArgs<T> eventArgs, string valueName)
{
if ((eventArgs.NewValue == null || eventArgs.OldValue == null))
{
if (!(eventArgs.NewValue == null && eventArgs.OldValue == null))
goto Log;
}
else if (!eventArgs.NewValue!.Equals(eventArgs.OldValue))
goto Log;
return;
Log:
string message = string.Create(CultureInfo.InvariantCulture, $"{valueName} set to: {eventArgs.NewValue}");
Logger.Info?.Print(logClass, message);