mirror of
https://github.com/moby/moby.git
synced 2026-08-08 00:52:17 +00:00
daemon/libnetwork/types: remove TransportPort.Equal()
The `TransporPort` type is comparable; it doesn't have fields that
require special handling. It's defined as;
// TransportPort represents a local Layer 4 endpoint
type TransportPort struct {
Proto Protocol
Port uint16
}
where `Protocol` is an int (with a stringer interface);
type Protocol uint8
So we can remove the `Equal` method, and simplify places where it's
compared.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -158,15 +158,9 @@ func compareConnConfig(a, b *connectivityConfiguration) bool {
|
||||
if a == nil || b == nil {
|
||||
return false
|
||||
}
|
||||
if len(a.ExposedPorts) != len(b.ExposedPorts) ||
|
||||
len(a.PortBindings) != len(b.PortBindings) {
|
||||
if !slices.Equal(a.ExposedPorts, b.ExposedPorts) {
|
||||
return false
|
||||
}
|
||||
for i := 0; i < len(a.ExposedPorts); i++ {
|
||||
if !a.ExposedPorts[i].Equal(&b.ExposedPorts[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(a.PortBindings); i++ {
|
||||
if !comparePortBinding(&a.PortBindings[i].PortBinding, &b.PortBindings[i].PortBinding) {
|
||||
return false
|
||||
|
||||
@@ -154,7 +154,7 @@ func matchLink(l stubFirewallerLink, parentIP, childIP netip.Addr, ports []types
|
||||
return false
|
||||
}
|
||||
for i, p := range l.ports {
|
||||
if !p.Equal(&ports[i]) {
|
||||
if p != ports[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,23 +43,6 @@ type TransportPort struct {
|
||||
Port uint16
|
||||
}
|
||||
|
||||
// Equal checks if this instance of TransportPort is equal to the passed one
|
||||
func (t *TransportPort) Equal(o *TransportPort) bool {
|
||||
if t == o {
|
||||
return true
|
||||
}
|
||||
|
||||
if o == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if t.Proto != o.Proto || t.Port != o.Port {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String returns the TransportPort structure in string form
|
||||
func (t *TransportPort) String() string {
|
||||
return fmt.Sprintf("%s/%d", t.Proto.String(), t.Port)
|
||||
|
||||
Reference in New Issue
Block a user