Skip to content

Commit 657bc31

Browse files
committed
perfsprint: add new options
1 parent f61b811 commit 657bc31

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

.golangci.next.reference.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,12 @@ linters:
22532253
# Enable/disable optimization of hex formatting.
22542254
# Default: true
22552255
hex-format: false
2256+
# Enable/disable optimization of concat loop.
2257+
# Default: true
2258+
concat-loop: false
2259+
# Optimization of `concat-loop` even with other operations.
2260+
# Default: false
2261+
loop-other-ops: true
22562262

22572263
prealloc:
22582264
# IMPORTANT: we don't recommend using this linter before doing performance profiling.

jsonschema/golangci.next.jsonschema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,6 +3004,16 @@
30043004
"description": "Enable/disable optimization of hex formatting.",
30053005
"type": "boolean",
30063006
"default": true
3007+
},
3008+
"concat-loop": {
3009+
"description": "Enable/disable optimization of concat loop.",
3010+
"type": "boolean",
3011+
"default": true
3012+
},
3013+
"loop-other-ops": {
3014+
"description": "Optimization of `concat-loop` even with other operations.",
3015+
"type": "boolean",
3016+
"default": false
30073017
}
30083018
}
30093019
},

pkg/config/linters_settings.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ var defaultLintersSettings = LintersSettings{
131131
StrConcat: true,
132132
BoolFormat: true,
133133
HexFormat: true,
134+
ConcatLoop: true,
134135
},
135136
Prealloc: PreallocSettings{
136137
Simple: true,
@@ -794,6 +795,9 @@ type PerfSprintSettings struct {
794795

795796
BoolFormat bool `mapstructure:"bool-format"`
796797
HexFormat bool `mapstructure:"hex-format"`
798+
799+
ConcatLoop bool `mapstructure:"concat-loop"`
800+
LoopOtherOps bool `mapstructure:"loop-other-ops"`
797801
}
798802

799803
type PreallocSettings struct {

pkg/golinters/perfsprint/perfsprint.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ func New(settings *config.PerfSprintSettings) *goanalysis.Linter {
2828

2929
cfg["bool-format"] = settings.BoolFormat
3030
cfg["hex-format"] = settings.HexFormat
31+
32+
cfg["concat-loop"] = settings.ConcatLoop
33+
cfg["loop-other-ops"] = settings.LoopOtherOps
3134
}
3235

3336
return goanalysis.

0 commit comments

Comments
 (0)