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

Use DateTimeFormatter.formatTo to directly append to StringBuilder #2515

Merged

Conversation

michaelbraun
Copy link
Contributor

In a few places in code, DateTimeFormatter.format(...) is called on an Instant, which creates a new String, when this is just appended to a StringBuilder. This can be improved by calling DateTimeFormatter.formatTo, passing in the StringBuilder, resulting in no intermediate String.

Checklist

  • Base your changes on 2.x branch if you are targeting Log4j 2; use main otherwise
  • ./mvnw verify succeeds (if it fails due to code formatting issues reported by Spotless, simply run ./mvnw spotless:apply and retry)
  • Non-trivial changes contain an entry file in the src/changelog/.2.x.x directory
  • Tests for the changes are provided
  • Commits are signed (optional, but highly recommended)

Copy link
Contributor

@ppkarwasz ppkarwasz left a comment

Choose a reason for hiding this comment

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

@michaelbraun,

Looks good to me. Thank you for your contribution.

@michaelbraun
Copy link
Contributor Author

@michaelbraun,

Looks good to me. Thank you for your contribution.

Does this change need a file in the changelog or additional tests before merging?

@ppkarwasz
Copy link
Contributor

I don't think additional tests are needed, since your changes should be covered by the current ones.

Please add a changelog entry.

@vy vy merged commit feaf123 into apache:2.x Apr 26, 2024
2 of 8 checks passed
@vy
Copy link
Member

vy commented Apr 26, 2024

@michaelbraun, thanks so much! 🙇
Please keep these contributions coming! 🙏

@vy vy self-assigned this Apr 26, 2024
@vy vy added enhancement Additions or updates to features api Affects the public API labels Apr 26, 2024
@vy vy added this to the 2.24.0 milestone Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Affects the public API enhancement Additions or updates to features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants