MCPcopy Index your code
hub / github.com/docker/docker-agent / uniqueNames

Function uniqueNames

pkg/runtime/runtime.go:967–986  ·  view source on GitHub ↗

uniqueNames drops empty entries and de-duplicates names. By default it keeps the first-seen order (meaningful for declaration/priority order); when sorted is true it orders the result case-insensitively instead.

(names []string, sorted bool)

Source from the content-addressed store, hash-verified

965// the first-seen order (meaningful for declaration/priority order); when sorted
966// is true it orders the result case-insensitively instead.
967func uniqueNames(names []string, sorted bool) []string {
968 seen := make(map[string]struct{}, len(names))
969 out := make([]string, 0, len(names))
970 for _, name := range names {
971 if name == "" {
972 continue
973 }
974 if _, dup := seen[name]; dup {
975 continue
976 }
977 seen[name] = struct{}{}
978 out = append(out, name)
979 }
980 if sorted {
981 slices.SortFunc(out, func(a, b string) int {
982 return strings.Compare(strings.ToLower(a), strings.ToLower(b))
983 })
984 }
985 return out
986}
987
988// CurrentAgentToolsetStatuses returns one ToolsetStatus per toolset of the
989// active agent. The list is in declaration order. Toolsets that wrap

Callers 3

TestUniqueNamesFunction · 0.85
AgentConfigInfoMethod · 0.85
configSkillNamesFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestUniqueNamesFunction · 0.68