From d70497976a4db417d864d2ec53a0034347ba006c Mon Sep 17 00:00:00 2001 From: Sasha Melentyev Date: Thu, 2 Jun 2022 12:19:51 +0300 Subject: [PATCH 1/2] feat(config): bump go version and add preallocation --- pkg/config/config.go | 2 +- pkg/config/linters_settings_gocritic.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 9536c80cd0d5..0da47c2b2060 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -66,5 +66,5 @@ func DetectGoVersion() string { return v } - return "1.17" + return "1.18" } diff --git a/pkg/config/linters_settings_gocritic.go b/pkg/config/linters_settings_gocritic.go index 9a3d03d93e2f..7f6905f5f952 100644 --- a/pkg/config/linters_settings_gocritic.go +++ b/pkg/config/linters_settings_gocritic.go @@ -47,7 +47,7 @@ func debugChecksListf(checks []string, format string, args ...interface{}) { } func stringsSliceToSet(ss []string) map[string]bool { - ret := map[string]bool{} + ret := make(map[string]bool, len(ss)) for _, s := range ss { ret[s] = true } @@ -72,7 +72,7 @@ func gocriticCheckerTagsDebugf() { tagToCheckers := buildGocriticTagToCheckersMap() - var allTags []string + allTags := make([]string, 0, len(tagToCheckers)) for tag := range tagToCheckers { allTags = append(allTags, tag) } @@ -114,7 +114,7 @@ func (s *GocriticSettings) InferEnabledChecks(log logutils.Log) { disabledByDefaultChecks := getDefaultDisabledGocriticCheckersNames() debugChecksListf(disabledByDefaultChecks, "Disabled by default") - var enabledChecks []string + enabledChecks := make([]string, 0, len(s.EnabledTags)+len(enabledByDefaultChecks)) // EnabledTags if len(s.EnabledTags) != 0 { @@ -192,7 +192,7 @@ func validateStringsUniq(ss []string) error { } func intersectStringSlice(s1, s2 []string) []string { - s1Map := make(map[string]struct{}) + s1Map := make(map[string]struct{}, len(s1)) for _, s := range s1 { s1Map[s] = struct{}{} } @@ -253,7 +253,7 @@ func (s *GocriticSettings) IsCheckEnabled(name string) bool { } func sprintAllowedCheckerNames(allowedNames map[string]bool) string { - var namesSlice []string + namesSlice := make([]string, 0, len(allowedNames)) for name := range allowedNames { namesSlice = append(namesSlice, name) } @@ -267,7 +267,7 @@ func sprintStrings(ss []string) string { // getAllCheckerNames returns a map containing all checker names supported by gocritic. func getAllCheckerNames() map[string]bool { - allCheckerNames := map[string]bool{} + allCheckerNames := make(map[string]bool, len(allGocriticCheckers)) for _, checker := range allGocriticCheckers { allCheckerNames[strings.ToLower(checker.Name)] = true } @@ -336,7 +336,7 @@ func (s *GocriticSettings) validateCheckerNames(log logutils.Log) error { } func (s *GocriticSettings) GetLowercasedParams() map[string]GocriticCheckSettings { - ret := map[string]GocriticCheckSettings{} + ret := make(map[string]GocriticCheckSettings, len(s.SettingsPerCheck)) for checker, params := range s.SettingsPerCheck { ret[strings.ToLower(checker)] = params } From fabce5b6885bed7cd1cc8f7f6e8fa74a5621d6bd Mon Sep 17 00:00:00 2001 From: Sasha Melentyev Date: Thu, 2 Jun 2022 12:35:12 +0300 Subject: [PATCH 2/2] feat(config): set old go version --- pkg/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 0da47c2b2060..9536c80cd0d5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -66,5 +66,5 @@ func DetectGoVersion() string { return v } - return "1.18" + return "1.17" }