From 5d63706cea0306c6e40174c9d5490d2279dba48a Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Tue, 31 Dec 2024 22:34:14 -0600 Subject: [PATCH] misc: Bake in ValueEqual logic into ReactiveEventArgs [ci skip] --- src/Ryujinx.Common/ReactiveObject.cs | 29 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Ryujinx.Common/ReactiveObject.cs b/src/Ryujinx.Common/ReactiveObject.cs index 7ff16f0cb..bb2ece81c 100644 --- a/src/Ryujinx.Common/ReactiveObject.cs +++ b/src/Ryujinx.Common/ReactiveObject.cs @@ -53,17 +53,9 @@ namespace Ryujinx.Common { public static void LogValueChange(LogClass logClass, ReactiveEventArgs 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; + if (eventArgs.AreValuesEqual) + return; - return; - - Log: string message = string.Create(CultureInfo.InvariantCulture, $"{valueName} set to: {eventArgs.NewValue}"); Logger.Info?.Print(logClass, message); @@ -76,5 +68,22 @@ namespace Ryujinx.Common { public T OldValue { get; } = oldValue; public T NewValue { get; } = newValue; + + public bool AreValuesEqual + { + get + { + if (OldValue == null && NewValue == null) + return true; + + if (OldValue == null && NewValue != null) + return false; + + if (OldValue != null && NewValue == null) + return false; + + return OldValue!.Equals(NewValue); + } + } } }