skanehira/docui

[Improvement] Preallocated Slice

d-kuro opened this issue · 0 comments

docui/panel/networkPanel.go

Lines 237 to 269 in 6a3f947

var keys []string
tmpMap := make(map[string]*Network)
for _, network := range n.Docker.Networks() {
if n.filter != "" {
if strings.Index(strings.ToLower(network.Name), strings.ToLower(n.filter)) == -1 {
continue
}
}
var containers string
net, err := n.Docker.NetworkInfo(network.ID)
if err != nil {
n.ErrMessage(err.Error(), n.name)
n.Logger.Error(err)
return
}
for _, endpoint := range net.Containers {
containers += fmt.Sprintf("%s ", endpoint.Name)
}
tmpMap[network.ID[:12]] = &Network{
ID: network.ID,
Name: network.Name,
Driver: network.Driver,
Scope: network.Scope,
Containers: containers,
}
keys = append(keys, network.ID[:12])
}