Skip to content

Commit

Permalink
upb: Update _upb_map_next signature to return a boolean and remove th…
Browse files Browse the repository at this point in the history
…e _nextmutable Map iterator API.

PiperOrigin-RevId: 730964212
  • Loading branch information
adazh authored and copybara-github committed Feb 25, 2025
1 parent 3369ca4 commit e4cdf44
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
5 changes: 2 additions & 3 deletions upb/message/internal/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,13 @@ UPB_INLINE void _upb_map_fromvalue(upb_value val, void* out, size_t size) {
}
}

UPB_INLINE void* _upb_map_next(const struct upb_Map* map, size_t* iter) {
UPB_INLINE bool _upb_map_next(const struct upb_Map* map, size_t* iter) {
upb_strtable_iter it;
it.t = &map->t.strtable;
it.index = *iter;
upb_strtable_next(&it);
*iter = it.index;
if (upb_strtable_done(&it)) return NULL;
return (void*)str_tabent(&it);
return !upb_strtable_done(&it);
}

UPB_INLINE void _upb_Map_Clear(struct upb_Map* map) {
Expand Down
11 changes: 0 additions & 11 deletions upb_generator/c/generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -676,17 +676,6 @@ void GenerateMapSetters(upb::FieldDefPtr field, const DefPoolPair& pools,
)cc",
msg_name, resolved_name, MapKeyCType(field),
FieldInitializer(pools, field, options), MapKeySize(field, "key"));
output(
R"cc(
UPB_INLINE $0 $1_$2_nextmutable($1* msg, size_t* iter) {
const upb_MiniTableField field = $3;
upb_Map* map = (upb_Map*)upb_Message_GetMap(UPB_UPCAST(msg), &field);
if (!map) return NULL;
return ($0)_upb_map_next(map, iter);
}
)cc",
CType(field), msg_name, resolved_name,
FieldInitializerStrong(pools, field, options));
}

void GenerateRepeatedSetters(upb::FieldDefPtr field, const DefPoolPair& pools,
Expand Down

0 comments on commit e4cdf44

Please sign in to comment.