Skip to content

Commit

Permalink
Add UnknownFieldSet.isEmpty
Browse files Browse the repository at this point in the history
Allows callers to check if field set is empty without cloning the map

PiperOrigin-RevId: 631237925
  • Loading branch information
mhansen authored and copybara-github committed May 7, 2024
1 parent 9de810a commit c56bddd
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 83,11 @@ public int hashCode() {
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.
Expand Down

0 comments on commit c56bddd

Please sign in to comment.