chore: use slices.Contains for linear search
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
eb186027a0
commit
2b09a26507
2 changed files with 5 additions and 18 deletions
|
|
@ -2,6 +2,7 @@ package coredeno
|
|||
|
||||
import (
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -25,20 +26,10 @@ func CheckPath(path string, allowed []string) bool {
|
|||
|
||||
// CheckNet returns true if the given host:port is in the allowed list.
|
||||
func CheckNet(addr string, allowed []string) bool {
|
||||
for _, a := range allowed {
|
||||
if a == addr {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(allowed, addr)
|
||||
}
|
||||
|
||||
// CheckRun returns true if the given command is in the allowed list.
|
||||
func CheckRun(cmd string, allowed []string) bool {
|
||||
for _, a := range allowed {
|
||||
if a == cmd {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(allowed, cmd)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"embed"
|
||||
goio "io"
|
||||
"slices"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
|
|
@ -29,12 +30,7 @@ type Features struct {
|
|||
|
||||
// IsEnabled returns true if the given feature is enabled.
|
||||
func (f *Features) IsEnabled(feature string) bool {
|
||||
for _, flag := range f.Flags {
|
||||
if flag == feature {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(f.Flags, feature)
|
||||
}
|
||||
|
||||
// Option is a function that configures the Core.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue