-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Cleanup String.format()
usage
#14404
Comments
I think we should use string concatenation (+) by default and only using the other alternatives when there is an actual reason. For example, in loggers or guava preconditions using their own |
@gortiz @shounakmk219 I see that there are a lot of usages of |
I think that is very subjective. People coming from C background may find it more readable, but people coming from more modern languages where strings can be concatenated with IMHO the only place use case In terms of performance it is always the worse alternative, given they are not optimized at compile time (like a macro in Rust would be). |
That makes sense to me as well, just figured I'd check in with you before making that change. I've refactored a lot of usages in my PR. Let me know if anything looks off! |
The poor performance of
String.format()
is brought up multiple times in different PR reviews (recently)We should either move to to using
+
orStringBuilder
instead ofString.format()
and cleanup the existing usage ofString.format()
with the decided option as well.ref - https://www.baeldung.com/java-string-concatenation-methods
The text was updated successfully, but these errors were encountered: