Skip to content

Commit 95f26b0

Browse files
committed
🔥 remove unused regex for dot-to-bracket key parsing in Decoder
1 parent 301c4d2 commit 95f26b0

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

QsNet/Internal/Decoder.cs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Collections.Generic;
44
using System.Linq;
55
using System.Text;
6-
using System.Text.RegularExpressions;
76
using QsNet.Enums;
87
using QsNet.Models;
98

@@ -18,23 +17,6 @@ internal static class Decoder
1817
internal static partial class Decoder
1918
#endif
2019
{
21-
/// <summary>
22-
/// Regular expression to match dots followed by non-dot and non-bracket characters.
23-
/// This is used to replace dots in keys with brackets for parsing.
24-
/// </summary>
25-
private static readonly Regex DotToBracket = MyRegex();
26-
27-
#if NETSTANDARD2_0
28-
private static readonly Regex MyRegexInstance = new(@"\.([^.\[]+)", RegexOptions.Compiled);
29-
private static Regex MyRegex()
30-
{
31-
return MyRegexInstance;
32-
}
33-
#else
34-
[GeneratedRegex(@"\.([^.\[]+)", RegexOptions.Compiled)]
35-
private static partial Regex MyRegex();
36-
#endif
37-
3820
private static Encoding Latin1Encoding =>
3921
#if NETSTANDARD2_0
4022
Encoding.GetEncoding(28591);
@@ -548,7 +530,13 @@ bool strictDepth
548530
}
549531

550532
#if NETSTANDARD2_0
551-
// Efficient case-insensitive ordinal string replace for NETSTANDARD2_0 (no regex, no allocations beyond matches)
533+
/// <summary>
534+
/// Efficient case-insensitive ordinal string replace for NETSTANDARD2_0 (no regex, no allocations beyond matches)
535+
/// </summary>
536+
/// <param name="input"></param>
537+
/// <param name="oldValue"></param>
538+
/// <param name="newValue"></param>
539+
/// <returns></returns>
552540
private static string ReplaceOrdinalIgnoreCase(string input, string oldValue, string newValue)
553541
{
554542
if (string.IsNullOrEmpty(input) || string.IsNullOrEmpty(oldValue))
@@ -574,7 +562,11 @@ private static string ReplaceOrdinalIgnoreCase(string input, string oldValue, st
574562
}
575563
#endif
576564

577-
// Helper for joining IEnumerable as comma-separated strings (avoiding LINQ)
565+
/// <summary>
566+
/// Helper for joining IEnumerable as comma-separated strings (avoiding LINQ)
567+
/// </summary>
568+
/// <param name="enumerable"></param>
569+
/// <returns></returns>
578570
private static string JoinAsCommaSeparatedStrings(IEnumerable enumerable)
579571
{
580572
var e = enumerable.GetEnumerator();
@@ -595,7 +587,7 @@ private static string JoinAsCommaSeparatedStrings(IEnumerable enumerable)
595587
}
596588

597589
var s = e.Current?.ToString() ?? string.Empty;
598-
sb!.Append(s);
590+
sb.Append(s);
599591
}
600592
}
601593
finally

0 commit comments

Comments
 (0)