libnetwork: Sandbox.resolveName: add fast-path for alias lookups
Skip faster when we're looking for aliases. Also check for the list of aliases to be empty, not just `nil` (although in practice it should be equivalent). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
9249b34be8
commit
f549aaa205
1 changed files with 5 additions and 6 deletions
|
@ -490,18 +490,17 @@ func (sb *Sandbox) ResolveName(name string, ipType int) ([]net.IP, bool) {
|
|||
|
||||
func (sb *Sandbox) resolveName(nameOrAlias string, networkName string, epList []*Endpoint, lookupAlias bool, ipType int) (_ []net.IP, ipv6Miss bool) {
|
||||
for _, ep := range epList {
|
||||
name := nameOrAlias
|
||||
nw := ep.getNetwork()
|
||||
if lookupAlias && len(ep.aliases) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
nw := ep.getNetwork()
|
||||
if networkName != "" && networkName != nw.Name() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := nameOrAlias
|
||||
if lookupAlias {
|
||||
if ep.aliases == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var ok bool
|
||||
ep.mu.Lock()
|
||||
name, ok = ep.aliases[nameOrAlias]
|
||||
|
|
Loading…
Add table
Reference in a new issue