From 146a362a59ffd64f45e436eb97035d03085692b4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 25 May 2026 10:01:11 +0300 Subject: style(repl): use map[string]struct{} for sets instead of map[string]bool Idiomatic Go uses struct{} for zero-allocation sets. Two locations: - GetCompletionTopics: seen deduplication map - init(): seenCat category deduplication map --- internal/repl/help.go | 8 ++++---- internal/repl/help_topics.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/repl/help.go b/internal/repl/help.go index 4c0691b..9796644 100644 --- a/internal/repl/help.go +++ b/internal/repl/help.go @@ -44,7 +44,7 @@ func GetAllTopics() []string { // GetCompletionTopics returns all help topics suitable for tab completion. // Includes operator names and aliases from all registered HelpTopic entries. func GetCompletionTopics() []string { - seen := make(map[string]bool) + seen := make(map[string]struct{}) var topics []string // Add all operator names (skip "help" itself — no need to complete help help) @@ -53,12 +53,12 @@ func GetCompletionTopics() []string { continue } topics = append(topics, op) - seen[op] = true + seen[op] = struct{}{} // Add aliases for _, a := range t.Aliases { - if !seen[a] { + if _, ok := seen[a]; !ok { topics = append(topics, a) - seen[a] = true + seen[a] = struct{}{} } } } diff --git a/internal/repl/help_topics.go b/internal/repl/help_topics.go index 34bb708..5c36140 100644 --- a/internal/repl/help_topics.go +++ b/internal/repl/help_topics.go @@ -503,14 +503,14 @@ var ( ) func init() { - seenCat := make(map[string]bool) + seenCat := make(map[string]struct{}) for i := range helpTopics { t := &helpTopics[i] for _, a := range t.Aliases { helpByAlias[a] = t } - if !seenCat[t.Category] { - seenCat[t.Category] = true + if _, ok := seenCat[t.Category]; !ok { + seenCat[t.Category] = struct{}{} categoryOrder = append(categoryOrder, t.Category) } helpByCat[t.Category] = append(helpByCat[t.Category], t.Operator) -- cgit v1.2.3