Skip to content

Commit

Permalink
Merge pull request #6 from enclave-networks/improve-perf-valueipaddre…
Browse files Browse the repository at this point in the history
…ss-compare

Improve correctness of ValueIpAddress compares based on family
  • Loading branch information
enclave-alistair authored Nov 7, 2022
2 parents 5931ec4 + f40fe80 commit 8b1636c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Enclave.FastPacket/ValueIpAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,18 @@ public override bool Equals(object? obj)
/// <inheritdoc />
public bool Equals(ValueIpAddress other)
{
if (_addrFamily != other._addrFamily)
{
return false;
}

if (_addrFamily == AddressFamily.InterNetwork)
{
return _addr1 == other._addr1;
}

return _addr1 == other._addr1 &&
_addr2 == other._addr2 &&
_addrFamily == other._addrFamily;
_addr2 == other._addr2;
}

/// <inheritdoc />
Expand Down

0 comments on commit 8b1636c

Please sign in to comment.