Merge pull request #1296 from hashicorp/f-fast-sync

agent: remove an N^2 check. See #1265
This commit is contained in:
James Phillips 2015-10-26 11:37:52 -07:00
commit b50b0a8526
1 changed files with 8 additions and 9 deletions

View File

@ -389,16 +389,15 @@ func (l *localState) setSyncState() error {
l.serviceStatus[id] = syncStatus{inSync: equal}
}
for id, _ := range l.checks {
// Sync any check which doesn't exist on the remote side
found := false
// Index the remote health checks to improve efficiency
checkIndex := make(map[string]*structs.HealthCheck, len(checks))
for _, check := range checks {
if check.CheckID == id {
found = true
break
checkIndex[check.CheckID] = check
}
}
if !found {
// Sync any check which doesn't exist on the remote side
for id, _ := range l.checks {
if _, ok := checkIndex[id]; !ok {
l.checkStatus[id] = syncStatus{inSync: false}
}
}