Merge pull request #29527 from vishnukothakapu/perf-strings-equalfold

Performance: Replace strings.ToLower with strings.EqualFold
This commit is contained in:
Jan Rodák 2026-08-17 21:59:25 +02:00 • committed by GitHub
commit 4b6873a5ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 7 additions and 7 deletions

View file

@ -731,7 +731,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil
// otherwise it returns true
func useLayers() string {
layers := os.Getenv("BUILDAH_LAYERS")
if strings.ToLower(layers) == "false" || layers == "0" {
if strings.EqualFold(layers, "false") || layers == "0" {
return "false"
}
return "true"

View file

@ -92,7 +92,7 @@ func (r *Runtime) newVolume(ctx context.Context, noCreatePluginVolume bool, opti
for key, val := range volume.config.Options {
switch strings.ToLower(key) {
case "device":
if strings.ToLower(volume.config.Options["type"]) == define.TypeBind {
if strings.EqualFold(volume.config.Options["type"], define.TypeBind) {
if err := fileutils.Exists(val); err != nil {
return nil, fmt.Errorf("invalid volume option %s for driver 'local': %w", key, err)
}

View file

@ -120,7 +120,7 @@ func createAnonymousFilterVolumeFunction(filterValues []string) (libpod.VolumeFi
return func(v *libpod.Volume) bool {
for _, val := range filterValues {
anon := v.Anonymous()
invert := strings.ToLower(val) == "false" || val == "0"
invert := strings.EqualFold(val, "false") || val == "0"
if invert {
anon = !anon
}

View file

@ -121,7 +121,7 @@ func setUpClusterClient(kconfig k8sAPI.Config, applyOptions entities.ApplyOption
caCertPool := x509.NewCertPool()
// Be insecure if user sets ca-cert-file flag to insecure
if strings.ToLower(caCertFile) == "insecure" {
if strings.EqualFold(caCertFile, "insecure") {
insecureSkipVerify = true
} else if caCertFile == "" {
caCertFile = kconfig.Clusters[0].Cluster.CertificateAuthority

View file

@ -1021,5 +1021,5 @@ func promptUpdateSystemConn() (bool, error) {
if err != nil {
return false, err
}
return strings.ToLower(answer)[0] == 'y', nil
return len(answer) > 0 && (answer[0] == 'y' || answer[0] == 'Y'), nil
}

View file

@ -171,7 +171,7 @@ func supportAmbientCapabilities() bool {
func shouldMask(mask string, unmask []string) bool {
for _, m := range unmask {
if strings.ToLower(m) == "all" {
if strings.EqualFold(m, "all") {
return false
}
for m1 := range strings.SplitSeq(m, ":") {

View file

@ -1215,7 +1215,7 @@ func ParseRestartPolicy(policy string) (string, uint, error) {
case 1:
// No retries specified
policyType = splitRestart[0]
if strings.ToLower(splitRestart[0]) == "never" {
if strings.EqualFold(splitRestart[0], "never") {
policyType = define.RestartPolicyNo
}
case 2: