Free, open-source Windows optimization tool for performance, privacy, and simplicity.
C# csharpdebloatdotnetgamingopen-sourceoptimizationoptimizeroptimizerduckperformanceprivacytweakertweakswindowswinui
chore(optimization): clean up code
itsfatduck43e286a5d722
diff --git a/optimizerDuck/src/Core/Defaults.cs b/optimizerDuck/src/Core/Defaults.csindex 8b4f04a..576bd1d 100644--- a/optimizerDuck/src/Core/Defaults.cs+++ b/optimizerDuck/src/Core/Defaults.cs@@ -70,7 +70,11 @@ public static class Defaultspublic static readonly Dictionary<string, string> SAFE_APPS = new(){+ // bing["Microsoft.BingWeather"] = "Weather",+ ["Microsoft.BingNews"] = "Bing News",+ ["Microsoft.BingSearch"] = "Bing Search",+["Microsoft.GetHelp"] = "Get Help",["Microsoft.GetStarted"] = "Get Started / Tips",["Microsoft.Messaging"] = "Messaging",diff --git a/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs b/optimizerDuck/src/Core/Helpers/OptimizationHelper.csindex d6b5010..5f6e839 100644--- a/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs+++ b/optimizerDuck/src/Core/Helpers/OptimizationHelper.cs@@ -126,25 +126,27 @@ public static class OptimizationHelpervar allSafe = raw.SafeApps.SelectMany(x => x).ToList();var allCaution = raw.CautionApps.SelectMany(x => x).ToList();-- int safeDisplayLength = allSafe.Any()+ // Display Length+ var safeDisplayLength = allSafe.Count != 0? allSafe.Max(x => Defaults.SAFE_APPS.TryGetValue(x.Name, out var dn) ? dn.Length : x.Name.Length): 0;- int cautionDisplayLength = allCaution.Any()+ var cautionDisplayLength = allCaution.Count != 0? allCaution.Max(x => Defaults.CAUTION_APPS.TryGetValue(x.Name, out var dn) ? dn.Length : x.Name.Length): 0;- var maxDisplayNameLength = Math.Max(safeDisplayLength, cautionDisplayLength) + 1;-- int safeVersionLength = allSafe.Any()- ? allSafe.Max(x => x.Version?.Length ?? 0)+ // Version Length+ var safeVersionLength = allSafe.Count != 0+ ? allSafe.Max(x => x.Version.Length): 0;- int cautionVersionLength = allCaution.Any()- ? allCaution.Max(x => x.Version?.Length ?? 0)+ var cautionVersionLength = allCaution.Count != 0+ ? allCaution.Max(x => x.Version.Length): 0;++ var maxDisplayNameLength = Math.Max(safeDisplayLength, cautionDisplayLength) + 1;+var maxVersionLength = Math.Max(safeVersionLength, cautionVersionLength) + 1;@@ -155,7 +157,7 @@ public static class OptimizationHelperreturn app with{DisplayName = display.PadRight(maxDisplayNameLength),- Version = (app.Version ?? string.Empty).PadRight(maxVersionLength)+ Version = app.Version.PadRight(maxVersionLength)};}).ToList(),allCaution.Select(app =>@@ -164,7 +166,7 @@ public static class OptimizationHelperreturn app with{DisplayName = display.PadRight(maxDisplayNameLength),- Version = (app.Version ?? string.Empty).PadRight(maxVersionLength)+ Version = app.Version.PadRight(maxVersionLength)};}).ToList());@@ -174,15 +176,18 @@ public static class OptimizationHelperif (classification.SafeApps.Count > 0){parts.Add($"[{Theme.Primary}]{classification.SafeApps.Count}[/] safe apps");- Log.LogDebug("Found {TotalSafeApps} safe apps: {SafeApps}", classification.SafeApps.Count, string.Join(", ", classification.SafeApps.Select(x => x.Name).ToList()));+ Log.LogDebug("Found {TotalSafeApps} safe apps: {SafeApps}", classification.SafeApps.Count,+ string.Join(", ", classification.SafeApps.Select(x => x.Name).ToList()));}+if (classification.CautionApps.Count > 0){parts.Add($"[{Theme.Primary}]{classification.CautionApps.Count}[/] caution apps");- Log.LogDebug("Found {TotalCautionApps} caution apps: {CautionApps}", classification.CautionApps.Count, string.Join(", ", classification.CautionApps.Select(x => x.Name).ToList()));+ Log.LogDebug("Found {TotalCautionApps} caution apps: {CautionApps}", classification.CautionApps.Count,+ string.Join(", ", classification.CautionApps.Select(x => x.Name).ToList()));}- if (parts.Any())+ if (parts.Count != 0)Log.LogInformation($"Found {string.Join(" and ", parts)}.");elseLog.LogWarning("No apps found.");@@ -190,15 +195,4 @@ public static class OptimizationHelperreturn classification;});}-- private static string ResolveDisplayName(string name, Dictionary<string, string> dict)- {- var lower = name.ToLowerInvariant();- if (dict.TryGetValue(lower, out var exact))- return exact;-- var suffix = dict.FirstOrDefault(kv => lower.EndsWith(kv.Key.ToLowerInvariant()));- return !string.IsNullOrEmpty(suffix.Value) ? suffix.Value : name;- }-}\ No newline at end of file