Micro-optimization: Move compilation of some Regex generation to compile time instead of runtime, make some static ones compiled (#20287)
Move compilation of some Regex generation to compile time instead of runtime, make some static ones compiled
This commit is contained in:
@@ -225,16 +225,18 @@ public static partial class NPocoDatabaseExtensions
|
||||
/// <returns></returns>
|
||||
public static string EscapeAtSymbols(string value)
|
||||
{
|
||||
if (value.Contains("@") == false)
|
||||
if (value.Contains('@') == false)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
// this fancy regex will only match a single @ not a double, etc...
|
||||
var regex = new Regex("(?<!@)@(?!@)");
|
||||
return regex.Replace(value, "@@");
|
||||
return AtRegex().Replace(value, "@@");
|
||||
}
|
||||
|
||||
[GeneratedRegex("(?<!@)@(?!@)")]
|
||||
private static partial Regex AtRegex();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the underlying connection as a typed connection - this is used to unwrap the profiled mini profiler stuff
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user