Skip to content

Commit 418d35a

Browse files
hazzikfredericDelaporte
authored andcommitted
Optimize empty arrays usages (#1490)
1 parent aada800 commit 418d35a

File tree

150 files changed

+349
-306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+349
-306
lines changed

src/NHibernate.DomainModel/Async/CustomPersister.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using NHibernate.Tuple.Entity;
2222
using NHibernate.Type;
2323
using NHibernate.Util;
24+
using Array = System.Array;
2425

2526
namespace NHibernate.DomainModel
2627
{

src/NHibernate.DomainModel/Baz.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ public void SetDefaults()
396396
StringArray = StringSet.ToArray();
397397
StringList = new List<string>(StringArray);
398398
IntArray = new int[] {1, 3, 3, 7};
399-
FooArray = new Foo[0];
399+
FooArray = Array.Empty<Foo>();
400400

401401
Customs = new List<string[]>();
402402
Customs.Add(new String[] {"foo", "bar"});

src/NHibernate.DomainModel/CustomPersister.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using NHibernate.Tuple.Entity;
1212
using NHibernate.Type;
1313
using NHibernate.Util;
14+
using Array = System.Array;
1415

1516
namespace NHibernate.DomainModel
1617
{
@@ -130,12 +131,12 @@ public bool[] PropertyInsertability
130131

131132
public ValueInclusion[] PropertyInsertGenerationInclusions
132133
{
133-
get { return new ValueInclusion[0]; }
134+
get { return Array.Empty<ValueInclusion>(); }
134135
}
135136

136137
public ValueInclusion[] PropertyUpdateGenerationInclusions
137138
{
138-
get { return new ValueInclusion[0]; }
139+
get { return Array.Empty<ValueInclusion>(); }
139140
}
140141

141142
public bool[] PropertyCheckability

src/NHibernate.Test/Async/Component/Basic/ComponentTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected override string MappingsAssembly
3232

3333
protected override System.Collections.IList Mappings
3434
{
35-
get { return new string[] { }; }
35+
get { return Array.Empty<string>(); }
3636
}
3737

3838
protected override void Configure(Configuration configuration)

src/NHibernate.Test/Async/DialectTest/DialectFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public async Task CurrentTimestampSelectionAsync()
6868

6969
using (var connection = await (sessions.ConnectionProvider.GetConnectionAsync(CancellationToken.None)))
7070
{
71-
var statement = driver.GenerateCommand(CommandType.Text, new SqlString(dialect.CurrentTimestampSelectString), new SqlType[0]);
71+
var statement = driver.GenerateCommand(CommandType.Text, new SqlString(dialect.CurrentTimestampSelectString), Array.Empty<SqlType>());
7272
statement.Connection = connection;
7373
using (var reader = await (statement.ExecuteReaderAsync()))
7474
{

src/NHibernate.Test/Async/Events/PostEvents/PostUpdateFixture.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//------------------------------------------------------------------------------
99

1010

11+
using System;
1112
using System.Collections;
1213
using System.Collections.Generic;
1314
using NHibernate.Event;
@@ -56,7 +57,7 @@ public async Task ImplicitFlushAsync()
5657
}
5758

5859
await (DbCleanupAsync());
59-
((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
60+
((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = Array.Empty<IPostUpdateEventListener>();
6061
}
6162

6263
[Test]
@@ -85,7 +86,7 @@ public async Task ExplicitUpdateAsync()
8586
}
8687

8788
await (DbCleanupAsync());
88-
((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
89+
((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = Array.Empty<IPostUpdateEventListener>();
8990
}
9091

9192
[Test]
@@ -123,7 +124,7 @@ public async Task WithDetachedObjectAsync()
123124
}
124125

125126
await (DbCleanupAsync());
126-
((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
127+
((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = Array.Empty<IPostUpdateEventListener>();
127128
}
128129

129130
[Test]
@@ -163,7 +164,7 @@ public async Task UpdateDetachedObjectAsync()
163164
}
164165

165166
await (DbCleanupAsync());
166-
((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
167+
((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = Array.Empty<IPostUpdateEventListener>();
167168
}
168169

169170
[Test]
@@ -202,7 +203,7 @@ public async Task UpdateDetachedObjectWithLockAsync()
202203
}
203204

204205
await (DbCleanupAsync());
205-
((DebugSessionFactory)Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
206+
((DebugSessionFactory)Sfi).EventListeners.PostUpdateEventListeners = Array.Empty<IPostUpdateEventListener>();
206207
}
207208
private async Task DbCleanupAsync(CancellationToken cancellationToken = default(CancellationToken))
208209
{

src/NHibernate.Test/Async/ExceptionsTest/NullQueryTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class NullQueryTestAsync : TestCase
2828

2929
protected override IList Mappings
3030
{
31-
get { return new string[0]; }
31+
get { return Array.Empty<string>(); }
3232
}
3333

3434
#endregion

src/NHibernate.Test/Async/Legacy/FumTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public async Task CriteriaCollectionAsync()
8686
Assert.IsTrue(b.MapComponent.Stringmap.Count == 2);
8787

8888
int none = (await (s.CreateCriteria(typeof(Fum))
89-
.Add(Expression.In("FumString", new string[0]))
89+
.Add(Expression.In("FumString", Array.Empty<string>()))
9090
.ListAsync())).Count;
9191
Assert.AreEqual(0, none);
9292

src/NHibernate.Test/Async/LinqBulkManipulation/Fixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace NHibernate.Test.LinqBulkManipulation
2525
[TestFixture]
2626
public class FixtureAsync : TestCase
2727
{
28-
protected override IList Mappings => new string[0];
28+
protected override IList Mappings => Array.Empty<string>();
2929

3030
protected override void Configure(Cfg.Configuration configuration)
3131
{
@@ -970,7 +970,7 @@ public async Task SimpleDeleteOnAnimalAsync()
970970
using (var t = s.BeginTransaction())
971971
{
972972
// Get rid of FK which may fail the test
973-
_doll.Friends = new Human[0];
973+
_doll.Friends = Array.Empty<Human>();
974974
await (s.UpdateAsync(_doll));
975975
await (t.CommitAsync());
976976
}
@@ -1029,7 +1029,7 @@ public async Task DeleteOnJoinedSubclassAsync()
10291029
using (var t = s.BeginTransaction())
10301030
{
10311031
// Get rid of FK which may fail the test
1032-
_doll.Friends = new Human[0];
1032+
_doll.Friends = Array.Empty<Human>();
10331033
await (s.UpdateAsync(_doll));
10341034
await (t.CommitAsync());
10351035
}

src/NHibernate.Test/Async/MappingByCode/IntegrationTests/NH2825/FixtureByCode.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//------------------------------------------------------------------------------
99

1010

11+
using System;
1112
using System.Collections;
1213
using NHibernate.Cfg.MappingSchema;
1314
using NHibernate.Mapping.ByCode;
@@ -21,7 +22,7 @@ public class FixtureByCodeAsync : FixtureAsync
2122
{
2223
protected override IList Mappings
2324
{
24-
get { return new string[0]; }
25+
get { return Array.Empty<string>(); }
2526
}
2627

2728
protected override string MappingsAssembly
@@ -63,4 +64,4 @@ private HbmMapping GetMappings()
6364
return mapper.CompileMappingForAllExplicitlyAddedEntities();
6465
}
6566
}
66-
}
67+
}

0 commit comments

Comments
 (0)