From 08fef959698ca70e3ef3445a3a3aac44b0fd703e Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 15 Jan 2016 10:18:40 -0800 Subject: [PATCH] Remove a String.Split --- .../TagHelpers/TagHelperParseTreeRewriter.cs | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNet.Razor/Parser/TagHelpers/TagHelperParseTreeRewriter.cs b/src/Microsoft.AspNet.Razor/Parser/TagHelpers/TagHelperParseTreeRewriter.cs index 163e80ab44..f9704e3441 100644 --- a/src/Microsoft.AspNet.Razor/Parser/TagHelpers/TagHelperParseTreeRewriter.cs +++ b/src/Microsoft.AspNet.Razor/Parser/TagHelpers/TagHelperParseTreeRewriter.cs @@ -324,12 +324,25 @@ namespace Microsoft.AspNet.Razor.Parser.TagHelpers.Internal childSpan = child as Span; } - var attributeName = childSpan - .Content - .Split(separator: new[] { '=' }, count: 2)[0] - .TrimStart(); + var start = 0; + for (; start < childSpan.Content.Length; start++) + { + if (!char.IsWhiteSpace(childSpan.Content[start])) + { + break; + } + } - attributeNames.Add(attributeName); + var end = 0; + for (end = start; end < childSpan.Content.Length; end++) + { + if (childSpan.Content[end] == '=') + { + break; + } + } + + attributeNames.Add(childSpan.Content.Substring(start, end - start)); } return attributeNames;