Compare commits

...

2 Commits

Author SHA1 Message Date
Oliver Booth 6743918f44
fix: slice from initial index 2023-08-08 22:25:23 +01:00
Oliver Booth 030e5fdd3d
perf: inline redundant var 2023-08-08 22:25:06 +01:00
1 changed files with 6 additions and 5 deletions

View File

@ -76,8 +76,7 @@ public sealed class TemplateInlineParser : InlineParser
ReadOnlySpan<char> result = ReadNext(argumentSpan, ref index, false, out bool hasValue); ReadOnlySpan<char> result = ReadNext(argumentSpan, ref index, false, out bool hasValue);
if (!hasValue) if (!hasValue)
{ {
var argument = result.ToString(); argumentList.Add(result.ToString());
argumentList.Add(argument);
continue; continue;
} }
@ -105,6 +104,8 @@ public sealed class TemplateInlineParser : InlineParser
out bool hasValue) out bool hasValue)
{ {
var isEscaped = false; var isEscaped = false;
int startIndex = index;
for (; index < argumentSpan.Length; index++) for (; index < argumentSpan.Length; index++)
{ {
char currentChar = argumentSpan[index]; char currentChar = argumentSpan[index];
@ -120,16 +121,16 @@ public sealed class TemplateInlineParser : InlineParser
case '|' when !isEscaped: case '|' when !isEscaped:
hasValue = false; hasValue = false;
return argumentSpan[..index]; return argumentSpan[startIndex..index];
case '=' when !isEscaped && !consumeToken: case '=' when !isEscaped && !consumeToken:
hasValue = true; hasValue = true;
return argumentSpan[..index]; return argumentSpan[startIndex..index];
} }
} }
hasValue = false; hasValue = false;
return argumentSpan[..index]; return argumentSpan[startIndex..index];
} }
private static ReadOnlySpan<char> ReadUntilClosure(ReadOnlySpan<char> input) private static ReadOnlySpan<char> ReadUntilClosure(ReadOnlySpan<char> input)