Skip to content

Commit 849527b

Browse files
committed
Reuse instance
1 parent a963467 commit 849527b

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

src/NHibernate.Test/NHSpecificTest/NH3957/ResultTransformerEqualityFixture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public void Setup()
3131
var hasherForAll = typeof(AliasToEntityMapResultTransformer)
3232
.GetField("Hasher", BindingFlags.Static | BindingFlags.NonPublic)
3333
.GetValue(null);
34-
TweakHashcode(typeof(DistinctRootEntityResultTransformer), hasherForAll);
3534
TweakHashcode(typeof(PassThroughResultTransformer), hasherForAll);
3635
TweakHashcode(typeof(RootEntityResultTransformer), hasherForAll);
3736
TweakHashcode(typeof(ToListResultTransformer), hasherForAll);
@@ -133,4 +132,4 @@ public void ToListEquality()
133132
Assert.IsTrue(transf2.Equals(transf1));
134133
}
135134
}
136-
}
135+
}

src/NHibernate/Criterion/CriteriaSpecification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static CriteriaSpecification()
3333
{
3434
AliasToEntityMap = new AliasToEntityMapResultTransformer();
3535
RootEntity = new RootEntityResultTransformer();
36-
DistinctRootEntity = new DistinctRootEntityResultTransformer();
36+
DistinctRootEntity = DistinctRootEntityResultTransformer.Instance;
3737
Projection = new PassThroughResultTransformer();
3838
InnerJoin = JoinType.InnerJoin;
3939
FullJoin = JoinType.FullJoin;

src/NHibernate/Linq/IntermediateHqlTree.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void AddDistinctRootOperator()
110110
if (!_hasDistinctRootOperator)
111111
{
112112
Expression<Func<IEnumerable<object>, IList>> x =
113-
l => new DistinctRootEntityResultTransformer().TransformList(l.ToList());
113+
l => Transformers.DistinctRootEntity.TransformList(l.ToList());
114114

115115
_listTransformers.Add(x);
116116
_hasDistinctRootOperator = true;

src/NHibernate/Transform/DistinctRootEntityResultTransformer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace NHibernate.Transform
1010
public class DistinctRootEntityResultTransformer : IResultTransformer, ITupleSubsetResultTransformer
1111
{
1212
private static readonly INHibernateLogger log = NHibernateLogger.For(typeof(DistinctRootEntityResultTransformer));
13-
private static readonly object Hasher = new object();
13+
internal static readonly DistinctRootEntityResultTransformer Instance = new DistinctRootEntityResultTransformer();
1414

1515
internal sealed class IdentityComparer : IEqualityComparer<object>
1616
{
@@ -81,7 +81,7 @@ public override bool Equals(object obj)
8181

8282
public override int GetHashCode()
8383
{
84-
return Hasher.GetHashCode();
84+
return Instance.GetHashCode();
8585
}
8686
}
8787
}

src/NHibernate/Transform/Transformers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static IResultTransformer AliasToBean<T>()
4444
return AliasToBean(typeof(T));
4545
}
4646

47-
public static readonly IResultTransformer DistinctRootEntity = new DistinctRootEntityResultTransformer();
47+
public static readonly IResultTransformer DistinctRootEntity = DistinctRootEntityResultTransformer.Instance;
4848

4949
public static IResultTransformer AliasToBeanConstructor(System.Reflection.ConstructorInfo constructor)
5050
{

0 commit comments

Comments
 (0)