Skip to content

Commit c4d893f

Browse files
Optimize MatchFirstHost with early return when no hosts configured (#84)
1 parent d6a3299 commit c4d893f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/host/root.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ func (h *Manager) MatchFirstHost(toMatch string) *Host {
7777
h.RLock()
7878
defer h.RUnlock()
7979

80+
if len(h.Hosts) == 0 {
81+
return nil
82+
}
83+
8084
if host, ok := h.cache[toMatch]; ok {
8185
host.logger.WithField("requested_host", toMatch).Debug("matched host from cache")
8286
return host

0 commit comments

Comments
 (0)