Skip to content

Commit

Permalink
Avoid allocating iterator in TextFormat printing UnknownFieldSet
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 632503842
  • Loading branch information
mhansen authored and copybara-github committed May 10, 2024
1 parent bc80135 commit 8c6e5b7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions java/core/src/main/java/com/google/protobuf/TextFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ private void printSingleField(

private static void printUnknownFields(
final UnknownFieldSet unknownFields, final TextGenerator generator) throws IOException {
if (unknownFields.isEmpty()) {
return;
}
for (Map.Entry<Integer, UnknownFieldSet.Field> entry : unknownFields.asMap().entrySet()) {
final int number = entry.getKey();
final UnknownFieldSet.Field field = entry.getValue();
Expand Down

0 comments on commit 8c6e5b7

Please sign in to comment.