Skip to content

perf: fix 34 self-detected performance issues#4

Merged
cschuman merged 1 commit into
mainfrom
feat/session-20260105-215918
Jan 6, 2026
Merged

perf: fix 34 self-detected performance issues#4
cschuman merged 1 commit into
mainfrom
feat/session-20260105-215918

Conversation

@cschuman

@cschuman cschuman commented Jan 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Ran goperf on itself and fixed all actionable performance issues
  • 147 issues → 113 issues (34 fixed)
  • Remaining 113 are false positives or low-priority suggestions

Changes

  • Slice preallocation: Convert var issues []Issue to make([]Issue, 0, N) across 25+ functions
  • String concatenation: Convert += to strings.Builder in benchmark.go
  • Map size hints: Add capacity hints in fixer.go
  • Line splitting: Preallocate in types.go splitLines()

Test plan

  • go build passes
  • go test ./... passes
  • ./goperf ./... runs successfully with reduced issue count

Run goperf on itself and fix all actionable issues:

Slice preallocation (33 fixes):
- Convert `var issues []Issue` to `make([]Issue, 0, N)` across
  25+ Check() functions in all rule files
- Preallocate in analyzer.go, fixer.go, main.go, types.go
- Add capacity hints to helper function return slices

String concatenation (1 fix):
- Convert += to strings.Builder in benchmark.go generateBenchmarkCode()
- Convert += to strings.Builder in benchmark.go joinPatterns()

Map size hints:
- Add size hint to byFile map in fixer.go

Line splitting optimization:
- Count newlines first to preallocate in types.go splitLines()

Results: 147 issues → 113 issues (34 fixed)
Remaining 113 are false positives (AST traversal loops) or
low-priority suggestions (benchmark recommendations).
@cschuman cschuman merged commit 730251b into main Jan 6, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant