Skip to content

Commit b25f922

Browse files
authored
Replace IdentitySet with HashSet<object> (nhibernate#2356)
1 parent 9427018 commit b25f922

File tree

8 files changed

+12
-10
lines changed

8 files changed

+12
-10
lines changed

src/NHibernate.Test/UtilityTest/IdentitySetFixture.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4-
using System.Runtime.CompilerServices;
54
using NHibernate.Util;
65
using NUnit.Framework;
76

@@ -10,6 +9,8 @@ namespace NHibernate.Test.UtilityTest
109
/// <summary>
1110
/// Test for the IdentityMap.
1211
/// </summary>
12+
// Since 5.3
13+
[Obsolete("This class has no more usages and will be removed in a future version")]
1314
[TestFixture]
1415
public class IdentitySetFixture
1516
{

src/NHibernate/Async/Engine/Query/HQLQueryPlan.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public async Task PerformListAsync(QueryParameters queryParameters, ISessionImpl
5858
}
5959

6060
IList combinedResults = results ?? new List<object>();
61-
IdentitySet distinction = new IdentitySet();
61+
var distinction = new HashSet<object>(ReferenceComparer<object>.Instance);
6262
int includedCount = -1;
6363
for (int i = 0; i < Translators.Length; i++)
6464
{

src/NHibernate/Async/Event/Default/DefaultDeleteEventListener.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public virtual Task OnDeleteAsync(DeleteEvent @event, CancellationToken cancella
3737
{
3838
return Task.FromCanceled<object>(cancellationToken);
3939
}
40-
return OnDeleteAsync(@event, new IdentitySet(), cancellationToken);
40+
return OnDeleteAsync(@event, new HashSet<object>(ReferenceComparer<object>.Instance), cancellationToken);
4141
}
4242

4343
public virtual async Task OnDeleteAsync(DeleteEvent @event, ISet<object> transientEntities, CancellationToken cancellationToken)
@@ -145,7 +145,7 @@ protected virtual async Task DeleteTransientEntityAsync(IEventSource session, ob
145145
// NH different impl : NH-1895
146146
if(transientEntities == null)
147147
{
148-
transientEntities = new HashSet<object>();
148+
transientEntities = new HashSet<object>(ReferenceComparer<object>.Instance);
149149
}
150150
if (!transientEntities.Add(entity))
151151
{

src/NHibernate/Async/Hql/Ast/ANTLR/QueryTranslatorImpl.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public async Task<IList> ListAsync(ISessionImplementor session, QueryParameters
7777

7878
int size = results.Count;
7979
var tmp = new List<object>();
80-
var distinction = new IdentitySet();
80+
var distinction = new HashSet<object>(ReferenceComparer<object>.Instance);
8181

8282
for ( int i = 0; i < size; i++ )
8383
{

src/NHibernate/Engine/Query/HQLQueryPlan.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void PerformList(QueryParameters queryParameters, ISessionImplementor ses
108108
}
109109

110110
IList combinedResults = results ?? new List<object>();
111-
IdentitySet distinction = new IdentitySet();
111+
var distinction = new HashSet<object>(ReferenceComparer<object>.Instance);
112112
int includedCount = -1;
113113
for (int i = 0; i < Translators.Length; i++)
114114
{

src/NHibernate/Event/Default/DefaultDeleteEventListener.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public partial class DefaultDeleteEventListener : IDeleteEventListener
2626
/// <param name="event">The delete event to be handled. </param>
2727
public virtual void OnDelete(DeleteEvent @event)
2828
{
29-
OnDelete(@event, new IdentitySet());
29+
OnDelete(@event, new HashSet<object>(ReferenceComparer<object>.Instance));
3030
}
3131

3232
public virtual void OnDelete(DeleteEvent @event, ISet<object> transientEntities)
@@ -143,7 +143,7 @@ protected virtual void DeleteTransientEntity(IEventSource session, object entity
143143
// NH different impl : NH-1895
144144
if(transientEntities == null)
145145
{
146-
transientEntities = new HashSet<object>();
146+
transientEntities = new HashSet<object>(ReferenceComparer<object>.Instance);
147147
}
148148
if (!transientEntities.Add(entity))
149149
{

src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public IList List(ISessionImplementor session, QueryParameters queryParameters)
123123

124124
int size = results.Count;
125125
var tmp = new List<object>();
126-
var distinction = new IdentitySet();
126+
var distinction = new HashSet<object>(ReferenceComparer<object>.Instance);
127127

128128
for ( int i = 0; i < size; i++ )
129129
{

src/NHibernate/Util/IdentitySet.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4-
using System.Linq;
54

65
namespace NHibernate.Util
76
{
87
/// <summary>
98
/// Set implementation that use reference equals instead of Equals() as its comparison mechanism.
109
/// </summary>
10+
// Since 5.3
11+
[Obsolete("This class has no more usages and will be removed in a future version")]
1112
public class IdentitySet : ISet<object>
1213
{
1314
private IDictionary map;

0 commit comments

Comments
 (0)