fix slice memory allocation optimization

This commit is contained in:
bonedaddy 2020-12-22 17:20:58 -08:00
commit 08cad808ef
No known key found for this signature in database
GPG key ID: 5386234333106B29
2 changed files with 5 additions and 5 deletions

View file

@ -37,7 +37,7 @@ func (ap *AccessPoint) MarshalJSON() ([]byte, error) {
doc := apJSON{
Station: ap.Station,
Clients: make([]*Station, len(ap.clients)),
Clients: make([]*Station, 0, len(ap.clients)),
Handshake: ap.withKeyMaterial,
}
@ -106,7 +106,7 @@ func (ap *AccessPoint) Clients() (list []*Station) {
ap.RLock()
defer ap.RUnlock()
list = make([]*Station, len(ap.clients))
list = make([]*Station, 0, len(ap.clients))
for _, c := range ap.clients {
list = append(list, c)
}