From 043ad5ce6e15586c7ecf266f8a45de948a5e4156 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 22 Aug 2023 12:30:15 -0700 Subject: [PATCH] We implement two functions to access map fields in UPB Go glue library: 1. getter function to access the upb_Map corresponding to a map proto field 2. conversion function to get a Go map from a upb_Map. The conversion function uses generics, so it must be a standalone function independent of `MessageAccessor`. Accessing map fields is not as efficient as accessing other proto field types, because of two reasons: - we need to make a copy of map values in Go, since the memory representations are different in UPB C - we need to call C functions from Go, because the upb_Map struct fields are not exported and we can't access the bits directly, causing performance overhead Luckily the map fields can be quite rare, so the performance overhead should not be too significant overall. PiperOrigin-RevId: 559191359 --- upb/base/string_view.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upb/base/string_view.h b/upb/base/string_view.h index b046f26a99..c9454b365b 100644 --- a/upb/base/string_view.h +++ b/upb/base/string_view.h @@ -47,7 +47,10 @@ typedef struct { const char* data; size_t size; } upb_StringView; -// LINT.ThenChange(GoogleInternalName0) +// LINT.ThenChange( +// GoogleInternalName0, +// //depot/google3/third_party/upb/bits/golang/accessor.go:map_go_string +// ) #ifdef __cplusplus extern "C" {