From f4651c9379de11c4a16ecce0122ea2cf53bd3471 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Thu, 20 May 2021 14:25:18 -0400 Subject: [PATCH] perf: Build only one logger for static style methods --- src/Uno.UI/UI/Xaml/Style/Style.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Style/Style.cs b/src/Uno.UI/UI/Xaml/Style/Style.cs index 4ca3e4956e3d..a05f71334bb9 100644 --- a/src/Uno.UI/UI/Xaml/Style/Style.cs +++ b/src/Uno.UI/UI/Xaml/Style/Style.cs @@ -14,6 +14,8 @@ namespace Windows.UI.Xaml [Markup.ContentProperty(Name = "Setters")] public partial class Style { + private static ILogger _logger = typeof(Style).Log(); + private delegate void ApplyToHandler(DependencyObject instance); public delegate Style StyleProviderHandler(); @@ -226,24 +228,24 @@ Style ProvideStyle() if (style == null && !useUWPDefaultStyles) { - if (typeof(Style).Log().IsEnabled(LogLevel.Debug)) + if (_logger.IsEnabled(LogLevel.Debug)) { - typeof(Style).Log().LogDebug($"No native style found for type {type}, falling back on UWP style"); + _logger.LogDebug($"No native style found for type {type}, falling back on UWP style"); } // If no native style found, fall back on UWP style style = GetDefaultStyleForType(type, useUWPDefaultStyles: true); } - if (typeof(Style).Log().IsEnabled(LogLevel.Debug)) + if (_logger.IsEnabled(LogLevel.Debug)) { if (style != null) { - typeof(Style).Log().LogDebug($"Returning {(useUWPDefaultStyles ? "UWP" : "native")} style {style} for type {type}"); + _logger.LogDebug($"Returning {(useUWPDefaultStyles ? "UWP" : "native")} style {style} for type {type}"); } else { - typeof(Style).Log().LogDebug($"No {(useUWPDefaultStyles ? "UWP" : "native")} style found for type {type}"); + _logger.LogDebug($"No {(useUWPDefaultStyles ? "UWP" : "native")} style found for type {type}"); } }