From acca83a6b100fd392b7311b85b96f4ec1925e20d Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 19 Oct 2016 13:50:18 +0200 Subject: [PATCH] Boot time optimization --- src/Umbraco.Core/StringExtensions.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index 8fb52e30eb..5b7eae36c1 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -124,11 +124,11 @@ namespace Umbraco.Core || (input.StartsWith("[") && input.EndsWith("]")); } - internal static readonly Regex Whitespace = new Regex(@"\s+", RegexOptions.Compiled); - internal static readonly string[] JsonEmpties = new [] { "[]", "{}" }; + internal static readonly Lazy Whitespace = new Lazy(() => new Regex(@"\s+", RegexOptions.Compiled)); + internal static readonly string[] JsonEmpties = { "[]", "{}" }; internal static bool DetectIsEmptyJson(this string input) { - return JsonEmpties.Contains(Whitespace.Replace(input, string.Empty)); + return JsonEmpties.Contains(Whitespace.Value.Replace(input, string.Empty)); } /// @@ -1322,10 +1322,10 @@ namespace Umbraco.Core // From: http://stackoverflow.com/a/961504/5018 // filters control characters but allows only properly-formed surrogate sequences - private static readonly Regex InvalidXmlChars = + private static readonly Lazy InvalidXmlChars = new Lazy(() => new Regex( @"(? @@ -1340,7 +1340,7 @@ namespace Umbraco.Core /// internal static string ToValidXmlString(this string text) { - return string.IsNullOrEmpty(text) ? text : InvalidXmlChars.Replace(text, ""); + return string.IsNullOrEmpty(text) ? text : InvalidXmlChars.Value.Replace(text, ""); } ///