Skip to content

Commit aa16ecb

Browse files
committed
xpending unit test; switch benchmark
1 parent ae78dab commit aa16ecb

7 files changed

Lines changed: 850 additions & 36 deletions

File tree

src/StackExchange.Redis/APITypes/LCSMatchResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public override int GetHashCode()
137137
/// <param name="first">The position of the matched substring in the first string.</param>
138138
/// <param name="second">The position of the matched substring in the second string.</param>
139139
/// <param name="length">The length of the match.</param>
140-
internal LCSMatch(LCSPosition first, LCSPosition second, long length)
140+
internal LCSMatch(in LCSPosition first, in LCSPosition second, long length)
141141
{
142142
_first = first;
143143
_second = second;

src/StackExchange.Redis/ResultProcessor.cs

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,39 +2102,18 @@ protected override bool SetResultCore(PhysicalConnection connection, Message mes
21022102
matchesArray = iter.Value.ReadPastArray(ref failed, static (ref failed, ref reader) =>
21032103
{
21042104
// Don't even bother if we've already failed
2105-
if (failed) return default;
2106-
2107-
if (!reader.IsAggregate)
2108-
{
2109-
failed = true;
2110-
return default;
2111-
}
2112-
2113-
var matchChildren = reader.AggregateChildren();
2114-
2115-
// First range (2-element array: [start, end])
2116-
if (!(matchChildren.MoveNext() && TryReadPosition(ref matchChildren.Value, out var firstPos)))
2117-
{
2118-
failed = true;
2119-
return default;
2120-
}
2121-
2122-
// Second range (2-element array: [start, end])
2123-
if (!(matchChildren.MoveNext() && TryReadPosition(ref matchChildren.Value, out var secondPos)))
2124-
{
2125-
failed = true;
2126-
return default;
2127-
}
2128-
2129-
// Length
2130-
if (!(matchChildren.MoveNext() && matchChildren.Value.IsScalar))
2105+
if (!failed && reader.IsAggregate)
21312106
{
2132-
failed = true;
2133-
return default;
2107+
var matchChildren = reader.AggregateChildren();
2108+
if (matchChildren.MoveNext() && TryReadPosition(ref matchChildren.Value, out var firstPos)
2109+
&& matchChildren.MoveNext() && TryReadPosition(ref matchChildren.Value, out var secondPos)
2110+
&& matchChildren.MoveNext() && matchChildren.Value.IsScalar && matchChildren.Value.TryReadInt64(out var length))
2111+
{
2112+
return new LCSMatchResult.LCSMatch(firstPos, secondPos, length);
2113+
}
21342114
}
2135-
var length = matchChildren.Value.TryReadInt64(out var matchLen) ? matchLen : 0;
2136-
2137-
return new LCSMatchResult.LCSMatch(firstPos, secondPos, length);
2115+
failed = true;
2116+
return default;
21382117
});
21392118

21402119
// Check if anything went wrong

0 commit comments

Comments
 (0)