Skip to content

Commit

Permalink
lookupd: enhance performance for nodes api
Browse files Browse the repository at this point in the history
  • Loading branch information
andyxning committed Nov 9, 2018
1 parent b0fb487 commit eb5944b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions nsqlookupd/registration_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,21 @@ func (r *RegistrationDB) FindProducers(category string, key string, subkey strin
return ProducerMap2Slice(r.registrationMap[k])
}

results := make(map[string]*Producer)
results := make(map[string]struct{})
var retProducers Producers
for k, producers := range r.registrationMap {
if !k.IsMatch(category, key, subkey) {
continue
}
for _, producer := range producers {
_, found := results[producer.peerInfo.id]
if found == false {
results[producer.peerInfo.id] = producer
results[producer.peerInfo.id] = struct{}{}
retProducers = append(retProducers, producer)
}
}
}
return ProducerMap2Slice(results)
return retProducers
}

func (r *RegistrationDB) LookupRegistrations(id string) Registrations {
Expand Down

0 comments on commit eb5944b

Please sign in to comment.