Skip to content

Commit

Permalink
Merge pull request #1296 from hashicorp/f-fast-sync
Browse files Browse the repository at this point in the history
agent: remove an N^2 check. See #1265
  • Loading branch information
slackpad committed Oct 26, 2015
2 parents 2aca5a9 + d137a5f commit f6b589d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions command/agent/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,15 @@ func (l *localState) setSyncState() error {
l.serviceStatus[id] = syncStatus{inSync: equal}
}

// Index the remote health checks to improve efficiency
checkIndex := make(map[string]*structs.HealthCheck, len(checks))
for _, check := range checks {
checkIndex[check.CheckID] = check
}

// Sync any check which doesn't exist on the remote side
for id, _ := range l.checks {
// Sync any check which doesn't exist on the remote side
found := false
for _, check := range checks {
if check.CheckID == id {
found = true
break
}
}
if !found {
if _, ok := checkIndex[id]; !ok {
l.checkStatus[id] = syncStatus{inSync: false}
}
}
Expand Down

0 comments on commit f6b589d

Please sign in to comment.