Add UnknownFieldSet.isEmpty

Allows callers to check if field set is empty without cloning the map

PiperOrigin-RevId: 631237925
pull/16747/head
Mark Hansen 11 months ago committed by Copybara-Service
parent 9de810acdc
commit c56bddd707
  1. 5
      java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java

@ -83,6 +83,11 @@ public final class UnknownFieldSet implements MessageLite {
return fields.hashCode();
}
/** Whether the field set has no fields. */
public boolean isEmpty() {
return fields.isEmpty();
}
/** Get a map of fields in the set by number. */
public Map<Integer, Field> asMap() {
// Avoid an allocation for the common case of an empty map.

Loading…
Cancel
Save