preallocate memory (#2201)
**What this PR does / why we need it:** Preallocate memory instead of enforcing an incremental growth. This will result in less work for the garbage collector.
This commit is contained in:
parent
cade15ea1b
commit
203f669ca8
@ -37,7 +37,7 @@ func GetViewersOverTime(w http.ResponseWriter, r *http.Request) {
|
||||
// GetActiveViewers returns currently connected clients.
|
||||
func GetActiveViewers(w http.ResponseWriter, r *http.Request) {
|
||||
c := core.GetActiveViewers()
|
||||
viewers := []models.Viewer{}
|
||||
viewers := make([]models.Viewer, 0, len(c))
|
||||
for _, v := range c {
|
||||
viewers = append(viewers, *v)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user