From d34286bf5d78a4ce7798887d8816043cbf8fcc63 Mon Sep 17 00:00:00 2001 From: niksedk Date: Thu, 27 Aug 2015 16:38:58 +0200 Subject: [PATCH] Performance improvement in HtmlUtil --- libse/HtmlUtil.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libse/HtmlUtil.cs b/libse/HtmlUtil.cs index 2542a5bd6..d585e177d 100644 --- a/libse/HtmlUtil.cs +++ b/libse/HtmlUtil.cs @@ -399,12 +399,13 @@ namespace Nikse.SubtitleEdit.Core return IsUrl(arr[0]); } + private static readonly string[] UppercaseTags = { "", "", "", "", "", "", "" }; + public static string FixUpperTags(string text) { if (string.IsNullOrEmpty(text)) return text; - var tags = new string[] { "", "", "", "", "", "", "" }; - var idx = text.IndexOfAny(tags, StringComparison.Ordinal); + var idx = text.IndexOfAny(UppercaseTags, StringComparison.Ordinal); while (idx >= 0) { var endIdx = text.IndexOf('>', idx + 2); @@ -412,7 +413,7 @@ namespace Nikse.SubtitleEdit.Core break; var tag = text.Substring(idx, endIdx - idx).ToLowerInvariant(); text = text.Remove(idx, endIdx - idx).Insert(idx, tag); - idx = text.IndexOfAny(tags, StringComparison.Ordinal); + idx = text.IndexOfAny(UppercaseTags, StringComparison.Ordinal); } return text; }