Skip to content

Conversation

@dulanting
Copy link

strings.Builder has fewer memory allocations and better performance.

More info: golang/go#75190

@dulanting
Copy link
Author

@nikoskarakostas @lukamindo Hi, Could you please review this PR at your convenience? Thank you very much.

@gipshtw gipshtw requested a review from Copilot November 3, 2025 20:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the DecimalExp function's performance by replacing string concatenation with strings.Builder for building zero padding, and updates comment formatting to follow Go documentation style guidelines.

  • Replaced inefficient string concatenation with strings.Builder in zero padding loop
  • Updated function documentation formatting to use proper Go comment list syntax

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

var zeros strings.Builder
for ; i < 0; i++ {
zeros += "0"
zeros.WriteString("0")
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Consider using WriteByte('0') instead of WriteString("0") for better performance when appending a single character. WriteByte is more efficient than WriteString for single-byte operations.

Suggested change
zeros.WriteString("0")
zeros.WriteByte('0')

Copilot uses AI. Check for mistakes.
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