Replace String.format
calls with string concatenation where possible
#3660
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This goes through our codebase and audits our
String.format
usage. It makes a few changes:String.format
call can be replaced withString
concatenation, it does so. This mainly means taking cases where strings or numbers are naively placed together (e.g.,String.format("%s -> %d", myStr, myInt)
) and replacing it with the equivalent concatentation (e.g.,myStr + " -> " + myInt
). The reason this is done is efficiency: it is more efficient to construct the strings and then concatenate them than to use the JavaString
formatter most of the time, mainly because the format string parsing is done at runtime with every invocation rather than compiled into some kind of formatting object.String.format
call has setLocale.ROOT
to avoid localization problems. This is what caused Metrics diff test uses locality for report formatting #3645, as theMetricsDiffAnalyzer
was formatting numbers with decimals, and then test asserts were firing if the test ran with a different locale, which is a thing we do in our nightly tests. In theory, that's actually sort of appropriate for a tool like this (for example, it would make sense to localize3.5
to3,5
if run on a system where that is the convention), but the rest of the product doesn't support it, and it's not like the actual text is localized.When running on a system with
Locale.ROOT
, this should be a transparent change.This fixes #3645.