server.MemberCount: count peers with len() is cheaper than loop

pull/820/head
Sergey Shepelev 2013-06-22 19:35:30 +04:00
parent f9ec2ed5eb
commit 19ad97520b
1 changed files with 1 additions and 5 deletions

View File

@ -189,11 +189,7 @@ func (s *Server) LastCommandName() string {
// Retrieves the number of member servers in the consensus.
func (s *Server) MemberCount() int {
count := 1
for _, _ = range s.peers {
count++
}
return count
return len(s.peers) + 1
}
// Retrieves the number of servers required to make a quorum.