Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit c22d9ee

Browse files
committed
Change to use TypeConstants when possible
1 parent a4579c8 commit c22d9ee

17 files changed

+172
-44
lines changed

lib/ServiceStack.Client.dll

1 KB
Binary file not shown.

lib/ServiceStack.Common.dll

512 Bytes
Binary file not shown.

lib/ServiceStack.Interfaces.dll

0 Bytes
Binary file not shown.

lib/ServiceStack.Text.dll

3 KB
Binary file not shown.

lib/signed/ServiceStack.Common.dll

512 Bytes
Binary file not shown.

lib/signed/ServiceStack.Text.XML

Lines changed: 125 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/signed/ServiceStack.Text.dll

0 Bytes
Binary file not shown.

src/ServiceStack.Redis/BasicRedisResolver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using ServiceStack.Logging;
5+
using ServiceStack.Text;
56

67
namespace ServiceStack.Redis
78
{
@@ -57,7 +58,7 @@ public virtual void ResetSlaves(IEnumerable<string> hosts)
5758

5859
public virtual void ResetSlaves(List<RedisEndpoint> newSlaves)
5960
{
60-
slaves = (newSlaves ?? new List<RedisEndpoint>()).ToArray();
61+
slaves = (newSlaves ?? TypeConstants<RedisEndpoint>.EmptyList).ToArray();
6162
ReadOnlyHostsCount = slaves.Length;
6263

6364
if (log.IsDebugEnabled)

src/ServiceStack.Redis/PooledRedisClientManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public partial class PooledRedisClientManager
5050
public IRedisResolver RedisResolver { get; set; }
5151
public List<Action<IRedisClientsManager>> OnFailover { get; private set; }
5252

53-
private RedisClient[] writeClients = new RedisClient[0];
53+
private RedisClient[] writeClients = TypeConstants<RedisClient>.EmptyArray;
5454
protected int WritePoolIndex;
5555

56-
private RedisClient[] readClients = new RedisClient[0];
56+
private RedisClient[] readClients = TypeConstants<RedisClient>.EmptyArray;
5757
protected int ReadPoolIndex;
5858

5959
protected int RedisClientCounter = 0;
@@ -120,8 +120,8 @@ public PooledRedisClientManager(
120120
? config.DefaultDb ?? initalDb
121121
: initalDb;
122122

123-
var masters = (readWriteHosts ?? new string[0]).ToArray();
124-
var slaves = (readOnlyHosts ?? new string[0]).ToArray();
123+
var masters = (readWriteHosts ?? TypeConstants.EmptyStringArray).ToArray();
124+
var slaves = (readOnlyHosts ?? TypeConstants.EmptyStringArray).ToArray();
125125

126126
RedisResolver = new RedisResolver(masters, slaves);
127127

src/ServiceStack.Redis/RedisExtensions.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
using System.Linq;
1717
using System.Net.Sockets;
1818
using ServiceStack.Model;
19+
using ServiceStack.Text;
1920

2021
namespace ServiceStack.Redis
2122
{
2223
public static class RedisExtensions
2324
{
2425
public static List<RedisEndpoint> ToRedisEndPoints(this IEnumerable<string> hosts)
2526
{
26-
return hosts == null
27-
? new List<RedisEndpoint>()
27+
return hosts == null
28+
? new List<RedisEndpoint>()
2829
: hosts.Select(x => ToRedisEndpoint(x)).ToList();
2930
}
3031

@@ -64,7 +65,7 @@ public static RedisEndpoint ToRedisEndpoint(this string connectionString, int? d
6465
var value = entry.Length > 1 ? entry[1].UrlDecode() : null;
6566
if (value == null) continue;
6667

67-
var name = entry[0].ToLower();
68+
var name = entry[0].ToLower();
6869
switch (name)
6970
{
7071
case "db":
@@ -149,7 +150,7 @@ public static List<string> ToStringList(this byte[][] multiDataList)
149150
public static string[] ToStringArray(this byte[][] multiDataList)
150151
{
151152
if (multiDataList == null)
152-
return new string[0];
153+
return TypeConstants.EmptyStringArray;
153154

154155
var to = new string[multiDataList.Length];
155156
for (int i = 0; i < multiDataList.Length; i++)
@@ -162,7 +163,7 @@ public static string[] ToStringArray(this byte[][] multiDataList)
162163
public static Dictionary<string, string> ToStringDictionary(this byte[][] multiDataList)
163164
{
164165
if (multiDataList == null)
165-
return new Dictionary<string, string>();
166+
return TypeConstants.EmptyStringDictionary;
166167

167168
var map = new Dictionary<string, string>();
168169

@@ -190,20 +191,20 @@ private static byte[] FastToUtf8Bytes(string strVal)
190191
{
191192
var bytes = new byte[strVal.Length];
192193
for (var i = 0; i < strVal.Length; i++)
193-
bytes[i] = (byte) strVal[i];
194+
bytes[i] = (byte)strVal[i];
194195

195196
return bytes;
196197
}
197198

198-
public static byte[][] ToMultiByteArray(this string[] args)
199-
{
200-
var byteArgs = new byte[args.Length][];
201-
for (var i = 0; i < args.Length; ++i)
202-
byteArgs[i] = args[i].ToUtf8Bytes();
203-
return byteArgs;
204-
}
199+
public static byte[][] ToMultiByteArray(this string[] args)
200+
{
201+
var byteArgs = new byte[args.Length][];
202+
for (var i = 0; i < args.Length; ++i)
203+
byteArgs[i] = args[i].ToUtf8Bytes();
204+
return byteArgs;
205+
}
205206

206-
public static byte[][] PrependByteArray(this byte[][] args, byte[] valueToPrepend)
207+
public static byte[][] PrependByteArray(this byte[][] args, byte[] valueToPrepend)
207208
{
208209
var newArgs = new byte[args.Length + 1][];
209210
newArgs[0] = valueToPrepend;
@@ -213,7 +214,7 @@ public static byte[][] PrependByteArray(this byte[][] args, byte[] valueToPrepe
213214

214215
return newArgs;
215216
}
216-
public static byte[][] PrependInt(this byte[][] args, int valueToPrepend)
217+
public static byte[][] PrependInt(this byte[][] args, int valueToPrepend)
217218
{
218219
return args.PrependByteArray(valueToPrepend.ToUtf8Bytes());
219220
}

0 commit comments

Comments
 (0)