Replace for loop with map
This mainly helps avoid loop inside a loop and iterating over all items
should be faster than directly seeking the value of a particular key,
no?
@@ -2094,12 +2094,11 @@ func (c *Client) GetServiceInstanceLabelValues(label string, selector string) ([
// Grab all the matched strings
var values []string
for _, elem := range svcList.Items {
- for key, val := range elem.Labels {
- if key == label {
+ val, ok := elem.Labels[label]
+ if ok {
values = append(values, val)
}
}
- }
// Sort alphabetically
sort.Strings(values)
