on main help sign in
refactor: migrate bool to empty struct for lower memory usage
9eb207fAndrey Nering
internal/shell/shell.go+4−3
@@ -157,16 +157,17 @@ func (s *Shell) SetBlockFuncs(blockFuncs []BlockFunc) {
157
157
158// CommandsBlocker creates a BlockFunc that blocks exact command matches
158// CommandsBlocker creates a BlockFunc that blocks exact command matches
159func CommandsBlocker(bannedCommands []string) BlockFunc {
159func CommandsBlocker(bannedCommands []string) BlockFunc {
160− bannedSet := make(map[string]bool)
160+ bannedSet := make(map[string]struct{})
161 for _, cmd := range bannedCommands {
161 for _, cmd := range bannedCommands {
162− bannedSet[cmd] = true
162+ bannedSet[cmd] = struct{}{}
163 }
163 }
164
164
165 return func(args []string) bool {
165 return func(args []string) bool {
166 if len(args) == 0 {
166 if len(args) == 0 {
167 return false
167 return false
168 }
168 }
169− return bannedSet[args[0]]
169+ _, ok := bannedSet[args[0]]
170+ return ok
170 }
171 }
171}
172}
172
173