Skip to content

Commit

Permalink
Improving performance
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov authored and NikolayPianikov committed Mar 4, 2022
1 parent d1d21bc commit 778b08e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Pure.DI/Components/Tables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Table(Pair<TKey, TValue>[] pairs)
var bucket = (uint)pair.Key.GetHashCode() % Divisor;
var next = Buckets[bucket];
Buckets[bucket] = pair;
if (next != emptyPair)
if (!ReferenceEquals(next, emptyPair))
{
pair.Next = next;
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public object Resolve(System.Type type)
var pair = ResolversBuckets[(uint)type.GetHashCode() % ResolversDivisor];
do
{
if (pair.Key == type)
if (ReferenceEquals(pair.Key, type))
{
return pair.Value();
}
Expand All @@ -138,7 +138,7 @@ internal System.Func<object> GetResolver<T>()
var pair = ResolversBuckets[(uint)typeof(T).GetHashCode() % ResolversDivisor];
do
{
if (pair.Key == typeof(T))
if (ReferenceEquals(pair.Key, typeof(T)))
{
return pair.Value;
}
Expand Down Expand Up @@ -176,7 +176,7 @@ public object Resolve(TagKey key)
do
{
// ReSharper disable once PossiblyImpureMethodCallOnReadonlyVariable
if (pair.Key.Type == key.Type && pair.Key.Tag.Equals(key.Tag))
if (ReferenceEquals(pair.Key.Type, key.Type) && pair.Key.Tag.Equals(key.Tag))
{
return pair.Value();
}
Expand All @@ -190,7 +190,7 @@ public object Resolve(TagKey key)
var typePair = ResolversBuckets[(uint)keyType.GetHashCode() % ResolversDivisor];
do
{
if (typePair.Key == keyType)
if (ReferenceEquals(typePair.Key, keyType))
{
return typePair.Value();
}
Expand Down Expand Up @@ -223,7 +223,7 @@ public TagKey(System.Type type, object tag)
// ReSharper disable once MemberCanBePrivate.Global
public bool Equals(TagKey other)
{
return Type == other.Type && Tag.Equals(other.Tag);
return ReferenceEquals(Type, other.Type) && Tag.Equals(other.Tag);
}

public override bool Equals(object obj)
Expand Down
1 change: 1 addition & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotnet csi /p target=Build /p version=1.1.35 Build\Program.csx

0 comments on commit 778b08e

Please sign in to comment.