这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@sunnyraindy
Copy link
Contributor

@sunnyraindy sunnyraindy commented Nov 10, 2025

strings.Builder has fewer memory allocations and better performance.
More info: golang/go#75190

Summary by CodeRabbit

  • Refactor
    • Improved internal performance and memory efficiency of the output processing system by optimizing how per-host source lists are assembled in memory, while preserving existing output format and behavior.

@coderabbitai
Copy link

coderabbitai bot commented Nov 10, 2025

Walkthrough

The writeSourcePlainHost function in pkg/runner/outputter.go was refactored to use strings.Builder instead of repeated string concatenation when assembling per-host source lists. Control flow and output formatting remain unchanged.

Changes

Cohort / File(s) Summary
String concatenation → strings.Builder
pkg/runner/outputter.go
Replaced string concatenation with a strings.Builder (WriteString / WriteRune) and used strings.TrimSuffix on the builder output to remove the trailing delimiter; no behavioral changes intended.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify correct use of strings.Builder APIs and final trimming (TrimSuffix) on builder.String().
  • Confirm identical output for edge cases (empty sources, single source, trailing delimiter).

Poem

🐰 I stitched the strings with gentle care,
A builder hummed where concat was bare,
Quiet bytes now hop and play,
Clean lines lead the carrot way! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring to use strings.Builder for performance improvement, which matches the PR's core objective of reducing memory allocations.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7212098 and d525551.

📒 Files selected for processing (1)
  • pkg/runner/outputter.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/runner/outputter.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3cb054d and 7212098.

📒 Files selected for processing (1)
  • pkg/runner/outputter.go (1 hunks)

Signed-off-by: sunnyraindy <sunnyraindy@outlook.com>
@dogancanbakir dogancanbakir merged commit 92bd205 into projectdiscovery:dev Nov 12, 2025
10 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.

2 participants