Commit 40498f55 authored by Marc Gravell's avatar Marc Gravell

Avoid implicit casts in RedisChannel prefix

parent a378428f
...@@ -754,7 +754,7 @@ protected RedisValue[] SortGetToInner(RedisValue[] outer) ...@@ -754,7 +754,7 @@ protected RedisValue[] SortGetToInner(RedisValue[] outer)
protected RedisChannel ToInner(RedisChannel outer) protected RedisChannel ToInner(RedisChannel outer)
{ {
return this.Prefix + outer; return RedisKey.Concatenate((byte[])Prefix, (byte[])outer);
} }
private Func<RedisKey, RedisKey> mapFunction; private Func<RedisKey, RedisKey> mapFunction;
......
...@@ -201,18 +201,22 @@ internal void AssertNotNull() ...@@ -201,18 +201,22 @@ internal void AssertNotNull()
/// </summary> /// </summary>
public static RedisKey operator +(RedisKey x, RedisKey y) public static RedisKey operator +(RedisKey x, RedisKey y)
{ {
byte[] xVal = x.value, yVal = y.value; return Concatenate(x.value, y.value);
}
internal static byte[] Concatenate(byte[] x, byte[] y)
{
// either null? yield the other; note this includes the "both null becomes null" case // either null? yield the other; note this includes the "both null becomes null" case
if (xVal == null) return y; if (x == null) return y;
if (yVal == null) return x; if (y == null) return x;
// either empty? yield the other // either empty? yield the other
if (xVal.Length == 0) return y; if (x.Length == 0) return y;
if (yVal.Length == 0) return x; if (y.Length == 0) return x;
byte[] result = new byte[xVal.Length + yVal.Length]; byte[] result = new byte[x.Length + y.Length];
Buffer.BlockCopy(xVal, 0, result, 0, xVal.Length); Buffer.BlockCopy(x, 0, result, 0, x.Length);
Buffer.BlockCopy(yVal, 0, result, xVal.Length, yVal.Length); Buffer.BlockCopy(y, 0, result, x.Length, y.Length);
return result; return result;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment