preallocate array
This commit is contained in:
@@ -52,9 +52,11 @@ func (cs *connectionStore) list() []*Connection {
|
|||||||
cs.rw.RLock()
|
cs.rw.RLock()
|
||||||
defer cs.rw.RUnlock()
|
defer cs.rw.RUnlock()
|
||||||
|
|
||||||
l := []*Connection{}
|
l := make([]*Connection, len(cs.items))
|
||||||
|
index := 0
|
||||||
for _, conn := range cs.items {
|
for _, conn := range cs.items {
|
||||||
l = append(l, conn)
|
l[index] = conn
|
||||||
|
index++
|
||||||
}
|
}
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user