Skip to content

Commit 9eeb34e

Browse files
committed
Fix small errors
1 parent f5bf604 commit 9eeb34e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Components/Endpoints/src/FormMapping/PrefixResolver.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ private class FormKeyComparer(bool checkPrefix) : IComparer<FormKey>
5050
// When comparing values, y is the element we are trying to find.
5151
public int Compare(FormKey x, FormKey y)
5252
{
53-
int separatorX = 0, separatorY = 0, currentXPos = 0, currentYPos = 0;
53+
var separatorX = 0;
54+
var separatorY = 0;
55+
var currentXPos = 0;
56+
var currentYPos = 0;
5457
while (separatorX != -1 && separatorY != -1)
5558
{
5659
separatorX = x.Value.Span[currentXPos..].IndexOfAny('.', '[');
@@ -65,7 +68,9 @@ public int Compare(FormKey x, FormKey y)
6568
else if (separatorX == -1)
6669
{
6770
// x has no more segments, y has remaining segments
68-
compare = MemoryExtensions.CompareTo(x.Value.Span[currentXPos..], y.Value.Span[currentYPos..][..separatorY], StringComparison.Ordinal);
71+
var segmentX = x.Value.Span[currentXPos..];
72+
var segmentY = y.Value.Span[currentYPos..][..separatorY];
73+
compare = MemoryExtensions.CompareTo(segmentX, segmentY, StringComparison.Ordinal);
6974
if (compare == 0 && !checkPrefix)
7075
{
7176
return -1;
@@ -75,7 +80,9 @@ public int Compare(FormKey x, FormKey y)
7580
else if (separatorY == -1)
7681
{
7782
// y has no more segments, x has remaining segments
78-
compare = MemoryExtensions.CompareTo(x.Value.Span[currentXPos..][..separatorX], y.Value.Span[currentYPos..], StringComparison.Ordinal);
83+
var segmentX = x.Value.Span[currentXPos..][..separatorX];
84+
var segmentY = y.Value.Span[currentYPos..];
85+
compare = MemoryExtensions.CompareTo(segmentX, segmentY, StringComparison.Ordinal);
7986
if (compare == 0 && !checkPrefix)
8087
{
8188
return 1;

0 commit comments

Comments
 (0)