| Index: third_party/protobuf/ruby/ext/google/protobuf_c/map.c
|
| diff --git a/third_party/protobuf/ruby/ext/google/protobuf_c/map.c b/third_party/protobuf/ruby/ext/google/protobuf_c/map.c
|
| index 92fc728666e933793a76cbe1a1437528dfe475a5..12f1f9ddd515fdfde9fdb8afe43abb18e6355dde 100644
|
| --- a/third_party/protobuf/ruby/ext/google/protobuf_c/map.c
|
| +++ b/third_party/protobuf/ruby/ext/google/protobuf_c/map.c
|
| @@ -63,16 +63,16 @@
|
| // construct a key byte sequence if needed. |out_key| and |out_length| provide
|
| // the resulting key data/length.
|
| #define TABLE_KEY_BUF_LENGTH 8 // sizeof(uint64_t)
|
| -static void table_key(Map* self, VALUE key,
|
| - char* buf,
|
| - const char** out_key,
|
| - size_t* out_length) {
|
| +static VALUE table_key(Map* self, VALUE key,
|
| + char* buf,
|
| + const char** out_key,
|
| + size_t* out_length) {
|
| switch (self->key_type) {
|
| case UPB_TYPE_BYTES:
|
| case UPB_TYPE_STRING:
|
| // Strings: use string content directly.
|
| Check_Type(key, T_STRING);
|
| - native_slot_validate_string_encoding(self->key_type, key);
|
| + key = native_slot_encode_and_freeze_string(self->key_type, key);
|
| *out_key = RSTRING_PTR(key);
|
| *out_length = RSTRING_LEN(key);
|
| break;
|
| @@ -93,6 +93,8 @@ static void table_key(Map* self, VALUE key,
|
| assert(false);
|
| break;
|
| }
|
| +
|
| + return key;
|
| }
|
|
|
| static VALUE table_key_to_ruby(Map* self, const char* buf, size_t length) {
|
| @@ -357,7 +359,7 @@ VALUE Map_index(VALUE _self, VALUE key) {
|
| const char* keyval = NULL;
|
| size_t length = 0;
|
| upb_value v;
|
| - table_key(self, key, keybuf, &keyval, &length);
|
| + key = table_key(self, key, keybuf, &keyval, &length);
|
|
|
| if (upb_strtable_lookup2(&self->table, keyval, length, &v)) {
|
| void* mem = value_memory(&v);
|
| @@ -383,7 +385,7 @@ VALUE Map_index_set(VALUE _self, VALUE key, VALUE value) {
|
| size_t length = 0;
|
| upb_value v;
|
| void* mem;
|
| - table_key(self, key, keybuf, &keyval, &length);
|
| + key = table_key(self, key, keybuf, &keyval, &length);
|
|
|
| mem = value_memory(&v);
|
| native_slot_set(self->value_type, self->value_type_class, mem, value);
|
| @@ -411,7 +413,7 @@ VALUE Map_has_key(VALUE _self, VALUE key) {
|
| char keybuf[TABLE_KEY_BUF_LENGTH];
|
| const char* keyval = NULL;
|
| size_t length = 0;
|
| - table_key(self, key, keybuf, &keyval, &length);
|
| + key = table_key(self, key, keybuf, &keyval, &length);
|
|
|
| if (upb_strtable_lookup2(&self->table, keyval, length, NULL)) {
|
| return Qtrue;
|
| @@ -434,7 +436,7 @@ VALUE Map_delete(VALUE _self, VALUE key) {
|
| const char* keyval = NULL;
|
| size_t length = 0;
|
| upb_value v;
|
| - table_key(self, key, keybuf, &keyval, &length);
|
| + key = table_key(self, key, keybuf, &keyval, &length);
|
|
|
| if (upb_strtable_remove2(&self->table, keyval, length, &v)) {
|
| void* mem = value_memory(&v);
|
|
|