Skip to content

Commit

Permalink
experimenting with RemoteActorRefProvider address resolution performa…
Browse files Browse the repository at this point in the history
…nce (#5228)

* experimenting with RemoteActorRefProvider address resolution performance

* implemented suggestions

* fixed `Address.==` and `Address.!=`

* fixed operators and generic equals

* cleaned up `Address.==`

* fixed `Address.==`
  • Loading branch information
Aaronontheweb authored Sep 8, 2021
1 parent 8a42eda commit 8f168fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/Akka.Remote/RemoteActorRefProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public Deploy LookUpRemotes(IEnumerable<string> p)

public bool HasAddress(Address address)
{
return address == _local.RootPath.Address || address == RootPath.Address || Transport.Addresses.Any(a => a == address);
return address.Equals(_local.RootPath.Address) || address.Equals(RootPath.Address) || Transport.Addresses.Contains(address);
}

/// <summary>
Expand Down
7 changes: 4 additions & 3 deletions src/core/Akka/Actor/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Xml.Xsl;
using Akka.Util;

namespace Akka.Actor
Expand Down Expand Up @@ -154,7 +155,7 @@ public bool Equals(Address other)
}

/// <inheritdoc/>
public override bool Equals(object obj) => obj is Address && Equals((Address)obj);
public override bool Equals(object obj) => Equals(obj as Address);

/// <inheritdoc/>
public override int GetHashCode()
Expand Down Expand Up @@ -245,7 +246,7 @@ public Address WithPort(int? port = null)
/// <returns><c>true</c> if both addresses are equal; otherwise <c>false</c></returns>
public static bool operator ==(Address left, Address right)
{
return Equals(left, right);
return left?.Equals(right) ?? ReferenceEquals(right, null);
}

/// <summary>
Expand All @@ -256,7 +257,7 @@ public Address WithPort(int? port = null)
/// <returns><c>true</c> if both addresses are not equal; otherwise <c>false</c></returns>
public static bool operator !=(Address left, Address right)
{
return !Equals(left, right);
return !(left == right);
}

/// <summary>
Expand Down

0 comments on commit 8f168fc

Please sign in to comment.