From 64a0d5993728f7408aff8bb6531c377f8698daf2 Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Wed, 17 Jul 2024 19:56:39 +0200 Subject: [PATCH] NLogMessageParameterList - Optimize index operator to skip paramater-name validation when no message template capture --- .../Logging/NLogMessageParameterList.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/NLog.Extensions.Logging/Logging/NLogMessageParameterList.cs b/src/NLog.Extensions.Logging/Logging/NLogMessageParameterList.cs index 52464bd0..cefc9614 100644 --- a/src/NLog.Extensions.Logging/Logging/NLogMessageParameterList.cs +++ b/src/NLog.Extensions.Logging/Logging/NLogMessageParameterList.cs @@ -97,7 +97,6 @@ private static bool IsValidParameterList(IReadOnlyList throw new NotSupportedException(); } + private static MessageTemplateParameter GetMessageTemplateParameter(string parameterName, object parameterValue) + { + var capture = GetCaptureType(parameterName[0]); + if (capture != CaptureType.Normal) + parameterName = parameterName.Substring(1); + return new MessageTemplateParameter(parameterName, parameterValue, null, capture); + } + private static CaptureType GetCaptureType(char firstChar) { if (firstChar == '@')