Skip to content

Commit c56bddd

Browse files
mhansencopybara-github
authored andcommitted
Add UnknownFieldSet.isEmpty
Allows callers to check if field set is empty without cloning the map PiperOrigin-RevId: 631237925
1 parent 9de810a commit c56bddd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public int hashCode() {
8383
return fields.hashCode();
8484
}
8585

86+
/** Whether the field set has no fields. */
87+
public boolean isEmpty() {
88+
return fields.isEmpty();
89+
}
90+
8691
/** Get a map of fields in the set by number. */
8792
public Map<Integer, Field> asMap() {
8893
// Avoid an allocation for the common case of an empty map.

0 commit comments

Comments
 (0)