Skip to content

Commit

Permalink
GODRIVER-2101 Use map 'ok' value
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvasquez committed Aug 31, 2023
1 parent d189587 commit 96c42ef
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions x/mongo/driver/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,21 +338,16 @@ func filterDeprioritizedServers(candidates, deprioritized []description.Server)
dpaSet[srv.Addr] = &deprioritized[i]
}

allowedIndexes := make([]int, 0, len(candidates))
allowed := []description.Server{}

// Iterate over the candidates and append them to the allowdIndexes slice if
// they are not in the deprioritizedServers list.
for i, candidate := range candidates {
if srv := dpaSet[candidate.Addr]; srv == nil || !srv.Equal(candidate) {
allowedIndexes = append(allowedIndexes, i)
for _, candidate := range candidates {
if srv, ok := dpaSet[candidate.Addr]; !ok || !srv.Equal(candidate) {
allowed = append(allowed, candidate)
}
}

allowed := make([]description.Server, len(allowedIndexes))
for i, idx := range allowedIndexes {
allowed[i] = candidates[idx]
}

// If nothing is allowed, then all available servers must have been
// deprioritized. In this case, return the candidates list as-is so that the
// selector can find a suitable server
Expand Down

0 comments on commit 96c42ef

Please sign in to comment.