From 6547118383e04824ba646a7bdbe9266c05f70848 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Mon, 24 Jul 2023 12:22:02 +0100 Subject: [PATCH] Reduce redundant logs when setting flags --- Bloxstrap/FastFlagManager.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Bloxstrap/FastFlagManager.cs b/Bloxstrap/FastFlagManager.cs index 97dcc6b..404528d 100644 --- a/Bloxstrap/FastFlagManager.cs +++ b/Bloxstrap/FastFlagManager.cs @@ -110,13 +110,19 @@ namespace Bloxstrap { if (value is null) { + if (Prop.ContainsKey(key)) + App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending"); + Prop.Remove(key); - App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending"); } else { + if (Prop.ContainsKey(key)) + App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' from '{Prop[key]}' to '{value}' is pending"); + else + App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' to '{value}' is pending"); + Prop[key] = value.ToString()!; - App.Logger.WriteLine($"[FastFlagManager::SetValue] Setting of '{key}' to '{value}' is pending"); } } @@ -157,13 +163,13 @@ namespace Bloxstrap public string GetPresetEnum(IReadOnlyDictionary mapping, string prefix, string value) { - foreach (var mode in mapping) + foreach (var pair in mapping) { - if (mode.Key == mapping.First().Key) + if (pair.Value == "None") continue; - if (App.FastFlags.GetPreset($"{prefix}.{mode.Value}") == value) - return mode.Key; + if (GetPreset($"{prefix}.{pair.Value}") == value) + return pair.Key; } return mapping.First().Key;