@@ -47,7 +47,7 @@ func debugChecksListf(checks []string, format string, args ...interface{}) {
47
47
}
48
48
49
49
func stringsSliceToSet (ss []string ) map [string ]bool {
50
- ret := map [string ]bool {}
50
+ ret := make ( map [string ]bool , len ( ss ))
51
51
for _ , s := range ss {
52
52
ret [s ] = true
53
53
}
@@ -72,7 +72,7 @@ func gocriticCheckerTagsDebugf() {
72
72
73
73
tagToCheckers := buildGocriticTagToCheckersMap ()
74
74
75
- var allTags []string
75
+ allTags := make ( []string , 0 , len ( tagToCheckers ))
76
76
for tag := range tagToCheckers {
77
77
allTags = append (allTags , tag )
78
78
}
@@ -114,7 +114,7 @@ func (s *GocriticSettings) InferEnabledChecks(log logutils.Log) {
114
114
disabledByDefaultChecks := getDefaultDisabledGocriticCheckersNames ()
115
115
debugChecksListf (disabledByDefaultChecks , "Disabled by default" )
116
116
117
- var enabledChecks []string
117
+ enabledChecks := make ( []string , 0 , len ( s . EnabledTags ) + len ( enabledByDefaultChecks ))
118
118
119
119
// EnabledTags
120
120
if len (s .EnabledTags ) != 0 {
@@ -192,7 +192,7 @@ func validateStringsUniq(ss []string) error {
192
192
}
193
193
194
194
func intersectStringSlice (s1 , s2 []string ) []string {
195
- s1Map := make (map [string ]struct {})
195
+ s1Map := make (map [string ]struct {}, len ( s1 ) )
196
196
for _ , s := range s1 {
197
197
s1Map [s ] = struct {}{}
198
198
}
@@ -253,7 +253,7 @@ func (s *GocriticSettings) IsCheckEnabled(name string) bool {
253
253
}
254
254
255
255
func sprintAllowedCheckerNames (allowedNames map [string ]bool ) string {
256
- var namesSlice []string
256
+ namesSlice := make ( []string , 0 , len ( allowedNames ))
257
257
for name := range allowedNames {
258
258
namesSlice = append (namesSlice , name )
259
259
}
@@ -267,7 +267,7 @@ func sprintStrings(ss []string) string {
267
267
268
268
// getAllCheckerNames returns a map containing all checker names supported by gocritic.
269
269
func getAllCheckerNames () map [string ]bool {
270
- allCheckerNames := map [string ]bool {}
270
+ allCheckerNames := make ( map [string ]bool , len ( allGocriticCheckers ))
271
271
for _ , checker := range allGocriticCheckers {
272
272
allCheckerNames [strings .ToLower (checker .Name )] = true
273
273
}
@@ -336,7 +336,7 @@ func (s *GocriticSettings) validateCheckerNames(log logutils.Log) error {
336
336
}
337
337
338
338
func (s * GocriticSettings ) GetLowercasedParams () map [string ]GocriticCheckSettings {
339
- ret := map [string ]GocriticCheckSettings {}
339
+ ret := make ( map [string ]GocriticCheckSettings , len ( s . SettingsPerCheck ))
340
340
for checker , params := range s .SettingsPerCheck {
341
341
ret [strings .ToLower (checker )] = params
342
342
}
0 commit comments