Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preallocate slices #2340

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/commands/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (e *Executor) executeLintersHelp(_ *cobra.Command, args []string) {
color.Green("\nLinters presets:")
for _, p := range e.DBManager.AllPresets() {
linters := e.DBManager.GetAllLinterConfigsForPreset(p)
linterNames := []string{}
linterNames := make([]string, 0, len(linters))
for _, lc := range linters {
linterNames = append(linterNames, lc.Name())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/wsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewWSL() *goanalysis.Linter {
).WithContextSetter(func(lintCtx *linter.Context) {
analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
var (
files = []string{}
files = make([]string, 0, len(pass.Files))
linterCfg = lintCtx.Cfg.LintersSettings.WSL
processorCfg = wsl.Configuration{
StrictAppend: linterCfg.StrictAppend,
Expand Down
2 changes: 1 addition & 1 deletion pkg/printers/codeclimate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewCodeClimate() *CodeClimate {
}

func (p CodeClimate) Print(ctx context.Context, issues []result.Issue) error {
codeClimateIssues := []CodeClimateIssue{}
codeClimateIssues := make([]CodeClimateIssue, 0, len(issues))
for i := range issues {
issue := &issues[i]
codeClimateIssue := CodeClimateIssue{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/result/processors/nolint.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (p Nolint) Finish() {
return
}

unknownLinters := []string{}
unknownLinters := make([]string, 0, len(p.unknownLintersSet))
for name := range p.unknownLintersSet {
unknownLinters = append(unknownLinters, name)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/timeutils/stopwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type stageDuration struct {
}

func (s *Stopwatch) stageDurationsSorted() []stageDuration {
stageDurations := []stageDuration{}
stageDurations := make([]stageDuration, 0, len(s.stages))
for n, d := range s.stages {
stageDurations = append(stageDurations, stageDuration{
name: n,
Expand All @@ -56,7 +56,7 @@ func (s *Stopwatch) sprintStages() string {

stageDurations := s.stageDurationsSorted()

stagesStrings := []string{}
stagesStrings := make([]string, 0, len(stageDurations))
for _, s := range stageDurations {
stagesStrings = append(stagesStrings, fmt.Sprintf("%s: %s", s.name, s.d))
}
Expand Down