From 1721d5a793f0428ff7a5d998993a0ff0f3d218f0 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Mon, 17 Jul 2023 08:53:34 -0400 Subject: [PATCH] Remove extra checks for known types in log formatter Turns out the JIT will not box in tier 1, this was trying to optimize tier 0 code. --- .../src/LogValuesFormatter.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs index 253c9f2ef1d31d..beae39c00287ad 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/LogValuesFormatter.cs @@ -265,13 +265,6 @@ private static object FormatArgument(object? value) private static bool TryFormatArgumentIfNullOrEnumerable(T? value, [NotNullWhen(true)] ref object? stringValue) { - // Avoiding boxing of known types - if (typeof(T).IsPrimitive || typeof(T).IsEnum) - { - stringValue = null; - return false; - } - if (value == null) { stringValue = NullValue;