google-protobuf 3.11.4-x86-linux → 3.12.0.rc.1-x86-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d61c7cc9be7942d97482de71ca9414238703d602efbc6116046d0411baaeab27
4
- data.tar.gz: 7691f2c8437d2d707702b637877daad6b6b75e99148ac4b21a7b17d3eb24237b
3
+ metadata.gz: b122c44b691de2ceba4149f7408a7405fa826828691d0b47f8412701c4d03329
4
+ data.tar.gz: 7267374a8a52e96ab7f9f093691a21e3ea2fbd7f56df9db29bec326c5175f707
5
5
  SHA512:
6
- metadata.gz: df3aabcdd2b730a0fad13d05cc339821296f5c346e47a8057c608935d1fa133a63df9990f18be70cbf4ca0e2d80d68dda447288eec3ab13e23938ba908630e31
7
- data.tar.gz: 2e85f485c8705b0df2e8b9033640d6aac19d0dadae36c3f7de2516691bdf4d0283a9f394e68137c46d1b3fc2d1e1fa903dca1bc4a8ac4b5b4de66706cff92588
6
+ metadata.gz: 03a4e465bef61a872fa57c0789d52645d71611d7ad40487221ea778fb9fbe4a1a4c26506f1166f9191a886f79083e82e94710bc62416a5b4d3456dc98ec2d86a
7
+ data.tar.gz: 2798b15c5cfc35f1444c3223bba5e119876e9b2796e0292d4f2f0a19c77f6f8fd92b81a0e96dcbd52021cbe628751de6f0f716dfda772df9870b069e605bf58e
@@ -136,7 +136,7 @@ static void rewrite_enum_default(const upb_symtab* symtab,
136
136
  * same number.
137
137
  *
138
138
  * Here we do a pass over all enum defaults and rewrite numeric defaults by
139
- * looking up their labels. This is compilcated by the fact that the enum
139
+ * looking up their labels. This is complicated by the fact that the enum
140
140
  * definition can live in either the symtab or the file_proto.
141
141
  * */
142
142
  static void rewrite_enum_defaults(
@@ -572,7 +572,7 @@ VALUE Descriptor_file_descriptor(VALUE _self) {
572
572
  * call-seq:
573
573
  * Descriptor.name => name
574
574
  *
575
- * Returns the name of this message type as a fully-qualfied string (e.g.,
575
+ * Returns the name of this message type as a fully-qualified string (e.g.,
576
576
  * My.Package.MessageType).
577
577
  */
578
578
  VALUE Descriptor_name(VALUE _self) {
@@ -1100,7 +1100,7 @@ VALUE FieldDescriptor_get(VALUE _self, VALUE msg_rb) {
1100
1100
  * FieldDescriptor.has?(message) => boolean
1101
1101
  *
1102
1102
  * Returns whether the value is set on the given message. Raises an
1103
- * exception when calling with proto syntax 3.
1103
+ * exception when calling for fields that do not have presence.
1104
1104
  */
1105
1105
  VALUE FieldDescriptor_has(VALUE _self, VALUE msg_rb) {
1106
1106
  DEFINE_SELF(FieldDescriptor, self, _self);
@@ -1434,6 +1434,7 @@ void MessageBuilderContext_register(VALUE module) {
1434
1434
  rb_define_method(klass, "initialize",
1435
1435
  MessageBuilderContext_initialize, 2);
1436
1436
  rb_define_method(klass, "optional", MessageBuilderContext_optional, -1);
1437
+ rb_define_method(klass, "proto3_optional", MessageBuilderContext_proto3_optional, -1);
1437
1438
  rb_define_method(klass, "required", MessageBuilderContext_required, -1);
1438
1439
  rb_define_method(klass, "repeated", MessageBuilderContext_repeated, -1);
1439
1440
  rb_define_method(klass, "map", MessageBuilderContext_map, -1);
@@ -1469,7 +1470,8 @@ VALUE MessageBuilderContext_initialize(VALUE _self,
1469
1470
 
1470
1471
  static void msgdef_add_field(VALUE msgbuilder_rb, upb_label_t label, VALUE name,
1471
1472
  VALUE type, VALUE number, VALUE type_class,
1472
- VALUE options, int oneof_index) {
1473
+ VALUE options, int oneof_index,
1474
+ bool proto3_optional) {
1473
1475
  DEFINE_SELF(MessageBuilderContext, self, msgbuilder_rb);
1474
1476
  FileBuilderContext* file_context =
1475
1477
  ruby_to_FileBuilderContext(self->file_builder);
@@ -1489,6 +1491,10 @@ static void msgdef_add_field(VALUE msgbuilder_rb, upb_label_t label, VALUE name,
1489
1491
  google_protobuf_FieldDescriptorProto_set_type(
1490
1492
  field_proto, (int)ruby_to_descriptortype(type));
1491
1493
 
1494
+ if (proto3_optional) {
1495
+ google_protobuf_FieldDescriptorProto_set_proto3_optional(field_proto, true);
1496
+ }
1497
+
1492
1498
  if (type_class != Qnil) {
1493
1499
  Check_Type(type_class, T_STRING);
1494
1500
 
@@ -1574,7 +1580,38 @@ VALUE MessageBuilderContext_optional(int argc, VALUE* argv, VALUE _self) {
1574
1580
  }
1575
1581
 
1576
1582
  msgdef_add_field(_self, UPB_LABEL_OPTIONAL, name, type, number, type_class,
1577
- options, -1);
1583
+ options, -1, false);
1584
+
1585
+ return Qnil;
1586
+ }
1587
+
1588
+ /*
1589
+ * call-seq:
1590
+ * MessageBuilderContext.proto3_optional(name, type, number,
1591
+ * type_class = nil, options = nil)
1592
+ *
1593
+ * Defines a true proto3 optional field (that tracks presence) on this message
1594
+ * type with the given type, tag number, and type class (for message and enum
1595
+ * fields). The type must be a Ruby symbol (as accepted by
1596
+ * FieldDescriptor#type=) and the type_class must be a string, if present (as
1597
+ * accepted by FieldDescriptor#submsg_name=).
1598
+ */
1599
+ VALUE MessageBuilderContext_proto3_optional(int argc, VALUE* argv,
1600
+ VALUE _self) {
1601
+ VALUE name, type, number;
1602
+ VALUE type_class, options = Qnil;
1603
+
1604
+ rb_scan_args(argc, argv, "32", &name, &type, &number, &type_class, &options);
1605
+
1606
+ // Allow passing (name, type, number, options) or
1607
+ // (name, type, number, type_class, options)
1608
+ if (argc == 4 && RB_TYPE_P(type_class, T_HASH)) {
1609
+ options = type_class;
1610
+ type_class = Qnil;
1611
+ }
1612
+
1613
+ msgdef_add_field(_self, UPB_LABEL_OPTIONAL, name, type, number, type_class,
1614
+ options, -1, true);
1578
1615
 
1579
1616
  return Qnil;
1580
1617
  }
@@ -1607,7 +1644,7 @@ VALUE MessageBuilderContext_required(int argc, VALUE* argv, VALUE _self) {
1607
1644
  }
1608
1645
 
1609
1646
  msgdef_add_field(_self, UPB_LABEL_REQUIRED, name, type, number, type_class,
1610
- options, -1);
1647
+ options, -1, false);
1611
1648
 
1612
1649
  return Qnil;
1613
1650
  }
@@ -1633,7 +1670,7 @@ VALUE MessageBuilderContext_repeated(int argc, VALUE* argv, VALUE _self) {
1633
1670
  type_class = (argc > 3) ? argv[3] : Qnil;
1634
1671
 
1635
1672
  msgdef_add_field(_self, UPB_LABEL_REPEATED, name, type, number, type_class,
1636
- Qnil, -1);
1673
+ Qnil, -1, false);
1637
1674
 
1638
1675
  return Qnil;
1639
1676
  }
@@ -1758,6 +1795,56 @@ VALUE MessageBuilderContext_oneof(VALUE _self, VALUE name) {
1758
1795
  return Qnil;
1759
1796
  }
1760
1797
 
1798
+ void MessageBuilderContext_add_synthetic_oneofs(VALUE _self) {
1799
+ DEFINE_SELF(MessageBuilderContext, self, _self);
1800
+ FileBuilderContext* file_context =
1801
+ ruby_to_FileBuilderContext(self->file_builder);
1802
+ size_t field_count, oneof_count;
1803
+ google_protobuf_FieldDescriptorProto** fields =
1804
+ google_protobuf_DescriptorProto_mutable_field(self->msg_proto, &field_count);
1805
+ const google_protobuf_OneofDescriptorProto*const* oneofs =
1806
+ google_protobuf_DescriptorProto_oneof_decl(self->msg_proto, &oneof_count);
1807
+ VALUE names = rb_hash_new();
1808
+ VALUE underscore = rb_str_new2("_");
1809
+ size_t i;
1810
+
1811
+ // We have to build a set of all names, to ensure that synthetic oneofs are
1812
+ // not creating conflicts.
1813
+ for (i = 0; i < field_count; i++) {
1814
+ upb_strview name = google_protobuf_FieldDescriptorProto_name(fields[i]);
1815
+ rb_hash_aset(names, rb_str_new(name.data, name.size), Qtrue);
1816
+ }
1817
+ for (i = 0; i < oneof_count; i++) {
1818
+ upb_strview name = google_protobuf_OneofDescriptorProto_name(oneofs[i]);
1819
+ rb_hash_aset(names, rb_str_new(name.data, name.size), Qtrue);
1820
+ }
1821
+
1822
+ for (i = 0; i < field_count; i++) {
1823
+ google_protobuf_OneofDescriptorProto* oneof_proto;
1824
+ VALUE oneof_name;
1825
+ upb_strview field_name;
1826
+
1827
+ if (!google_protobuf_FieldDescriptorProto_proto3_optional(fields[i])) {
1828
+ continue;
1829
+ }
1830
+
1831
+ // Prepend '_' until we are no longer conflicting.
1832
+ field_name = google_protobuf_FieldDescriptorProto_name(fields[i]);
1833
+ oneof_name = rb_str_new(field_name.data, field_name.size);
1834
+ while (rb_hash_lookup(names, oneof_name) != Qnil) {
1835
+ oneof_name = rb_str_plus(underscore, oneof_name);
1836
+ }
1837
+
1838
+ rb_hash_aset(names, oneof_name, Qtrue);
1839
+ google_protobuf_FieldDescriptorProto_set_oneof_index(fields[i],
1840
+ oneof_count++);
1841
+ oneof_proto = google_protobuf_DescriptorProto_add_oneof_decl(
1842
+ self->msg_proto, file_context->arena);
1843
+ google_protobuf_OneofDescriptorProto_set_name(
1844
+ oneof_proto, FileBuilderContext_strdup(self->file_builder, oneof_name));
1845
+ }
1846
+ }
1847
+
1761
1848
  // -----------------------------------------------------------------------------
1762
1849
  // OneofBuilderContext.
1763
1850
  // -----------------------------------------------------------------------------
@@ -1829,7 +1916,7 @@ VALUE OneofBuilderContext_optional(int argc, VALUE* argv, VALUE _self) {
1829
1916
  rb_scan_args(argc, argv, "32", &name, &type, &number, &type_class, &options);
1830
1917
 
1831
1918
  msgdef_add_field(self->message_builder, UPB_LABEL_OPTIONAL, name, type,
1832
- number, type_class, options, self->oneof_index);
1919
+ number, type_class, options, self->oneof_index, false);
1833
1920
 
1834
1921
  return Qnil;
1835
1922
  }
@@ -2033,6 +2120,7 @@ VALUE FileBuilderContext_add_message(VALUE _self, VALUE name) {
2033
2120
  VALUE ctx = rb_class_new_instance(2, args, cMessageBuilderContext);
2034
2121
  VALUE block = rb_block_proc();
2035
2122
  rb_funcall_with_block(ctx, rb_intern("instance_eval"), 0, NULL, block);
2123
+ MessageBuilderContext_add_synthetic_oneofs(ctx);
2036
2124
  return Qnil;
2037
2125
  }
2038
2126
 
@@ -30,6 +30,10 @@
30
30
 
31
31
  #include "protobuf.h"
32
32
 
33
+ VALUE initialize_rb_class_with_no_args(VALUE klass) {
34
+ return rb_funcall(klass, rb_intern("new"), 0);
35
+ }
36
+
33
37
  // This function is equivalent to rb_str_cat(), but unlike the real
34
38
  // rb_str_cat(), it doesn't leak memory in some versions of Ruby.
35
39
  // For more information, see:
@@ -295,7 +299,7 @@ static void *appendsubmsg_handler(void *closure, const void *hd) {
295
299
  const submsg_handlerdata_t *submsgdata = hd;
296
300
  MessageHeader* submsg;
297
301
 
298
- VALUE submsg_rb = rb_class_new_instance(0, NULL, submsgdata->subklass);
302
+ VALUE submsg_rb = initialize_rb_class_with_no_args(submsgdata->subklass);
299
303
  RepeatedField_push(ary, submsg_rb);
300
304
 
301
305
  TypedData_Get_Struct(submsg_rb, MessageHeader, &Message_type, submsg);
@@ -322,7 +326,7 @@ static void *submsg_handler(void *closure, const void *hd) {
322
326
 
323
327
  if (DEREF(msg, submsgdata->ofs, VALUE) == Qnil) {
324
328
  DEREF(msg, submsgdata->ofs, VALUE) =
325
- rb_class_new_instance(0, NULL, submsgdata->subklass);
329
+ initialize_rb_class_with_no_args(submsgdata->subklass);
326
330
  }
327
331
 
328
332
  set_hasbit(closure, submsgdata->hasbit);
@@ -430,10 +434,8 @@ static void *startmap_handler(void *closure, const void *hd) {
430
434
  }
431
435
 
432
436
  static bool endmap_handler(void *closure, const void *hd) {
433
- MessageHeader* msg = closure;
434
- const map_handlerdata_t* mapdata = hd;
435
- VALUE map_rb = DEREF(msg, mapdata->ofs, VALUE);
436
- Map_set_frame(map_rb, Qnil);
437
+ map_parse_frame_t* frame = closure;
438
+ Map_set_frame(frame->map, Qnil);
437
439
  return true;
438
440
  }
439
441
 
@@ -549,7 +551,7 @@ static void *oneofsubmsg_handler(void *closure,
549
551
  if (oldcase != oneofdata->oneof_case_num ||
550
552
  DEREF(msg, oneofdata->ofs, VALUE) == Qnil) {
551
553
  DEREF(msg, oneofdata->ofs, VALUE) =
552
- rb_class_new_instance(0, NULL, oneofdata->subklass);
554
+ initialize_rb_class_with_no_args(oneofdata->subklass);
553
555
  }
554
556
  // Set the oneof case *after* allocating the new class instance -- otherwise,
555
557
  // if the Ruby GC is invoked as part of a call into the VM, it might invoke
@@ -931,7 +933,7 @@ void add_handlers_for_message(const void *closure, upb_handlers *h) {
931
933
  !upb_msg_field_done(&i);
932
934
  upb_msg_field_next(&i)) {
933
935
  const upb_fielddef *f = upb_msg_iter_field(&i);
934
- const upb_oneofdef *oneof = upb_fielddef_containingoneof(f);
936
+ const upb_oneofdef* oneof = upb_fielddef_realcontainingoneof(f);
935
937
  size_t offset = get_field_offset(desc->layout, f);
936
938
 
937
939
  if (oneof) {
@@ -1038,7 +1040,7 @@ VALUE Message_decode(VALUE klass, VALUE data) {
1038
1040
  rb_raise(rb_eArgError, "Expected string for binary protobuf data.");
1039
1041
  }
1040
1042
 
1041
- msg_rb = rb_class_new_instance(0, NULL, msgklass);
1043
+ msg_rb = initialize_rb_class_with_no_args(msgklass);
1042
1044
  TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
1043
1045
 
1044
1046
  {
@@ -1114,7 +1116,7 @@ VALUE Message_decode_json(int argc, VALUE* argv, VALUE klass) {
1114
1116
  // convert, because string handlers pass data directly to message string
1115
1117
  // fields.
1116
1118
 
1117
- msg_rb = rb_class_new_instance(0, NULL, msgklass);
1119
+ msg_rb = initialize_rb_class_with_no_args(msgklass);
1118
1120
  TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
1119
1121
 
1120
1122
  {
@@ -1196,7 +1198,7 @@ static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink sink,
1196
1198
 
1197
1199
  upb_sink_startsubmsg(sink, getsel(f, UPB_HANDLER_STARTSUBMSG), &subsink);
1198
1200
  putmsg(submsg, subdesc, subsink, depth + 1, emit_defaults, is_json, true);
1199
- upb_sink_endsubmsg(sink, getsel(f, UPB_HANDLER_ENDSUBMSG));
1201
+ upb_sink_endsubmsg(sink, subsink, getsel(f, UPB_HANDLER_ENDSUBMSG));
1200
1202
  }
1201
1203
 
1202
1204
  static void putary(VALUE ary, const upb_fielddef* f, upb_sink sink, int depth,
@@ -1341,7 +1343,7 @@ static void putmap(VALUE map, const upb_fielddef* f, upb_sink sink, int depth,
1341
1343
  entry_sink, emit_defaults, is_json);
1342
1344
 
1343
1345
  upb_sink_endmsg(entry_sink, &status);
1344
- upb_sink_endsubmsg(subsink, getsel(f, UPB_HANDLER_ENDSUBMSG));
1346
+ upb_sink_endsubmsg(subsink, entry_sink, getsel(f, UPB_HANDLER_ENDSUBMSG));
1345
1347
  }
1346
1348
 
1347
1349
  upb_sink_endseq(sink, getsel(f, UPB_HANDLER_ENDSEQ));
@@ -1504,7 +1506,7 @@ static void putmsg(VALUE msg_rb, const Descriptor* desc,
1504
1506
  !upb_msg_field_done(&i);
1505
1507
  upb_msg_field_next(&i)) {
1506
1508
  upb_fielddef *f = upb_msg_iter_field(&i);
1507
- const upb_oneofdef *oneof = upb_fielddef_containingoneof(f);
1509
+ const upb_oneofdef* oneof = upb_fielddef_realcontainingoneof(f);
1508
1510
  bool is_matching_oneof = false;
1509
1511
  uint32_t offset =
1510
1512
  desc->layout->fields[upb_fielddef_index(f)].offset +
@@ -1712,7 +1714,7 @@ static void discard_unknown(VALUE msg_rb, const Descriptor* desc) {
1712
1714
  !upb_msg_field_done(&it);
1713
1715
  upb_msg_field_next(&it)) {
1714
1716
  upb_fielddef *f = upb_msg_iter_field(&it);
1715
- const upb_oneofdef *oneof = upb_fielddef_containingoneof(f);
1717
+ const upb_oneofdef* oneof = upb_fielddef_realcontainingoneof(f);
1716
1718
  uint32_t offset =
1717
1719
  desc->layout->fields[upb_fielddef_index(f)].offset +
1718
1720
  sizeof(MessageHeader);
File without changes
@@ -100,11 +100,11 @@ static VALUE table_key(Map* self, VALUE key,
100
100
  return key;
101
101
  }
102
102
 
103
- static VALUE table_key_to_ruby(Map* self, const char* buf, size_t length) {
103
+ static VALUE table_key_to_ruby(Map* self, upb_strview key) {
104
104
  switch (self->key_type) {
105
105
  case UPB_TYPE_BYTES:
106
106
  case UPB_TYPE_STRING: {
107
- VALUE ret = rb_str_new(buf, length);
107
+ VALUE ret = rb_str_new(key.data, key.size);
108
108
  rb_enc_associate(ret,
109
109
  (self->key_type == UPB_TYPE_BYTES) ?
110
110
  kRubyString8bitEncoding : kRubyStringUtf8Encoding);
@@ -116,7 +116,7 @@ static VALUE table_key_to_ruby(Map* self, const char* buf, size_t length) {
116
116
  case UPB_TYPE_INT64:
117
117
  case UPB_TYPE_UINT32:
118
118
  case UPB_TYPE_UINT64:
119
- return native_slot_get(self->key_type, Qnil, buf);
119
+ return native_slot_get(self->key_type, Qnil, key.data);
120
120
 
121
121
  default:
122
122
  assert(false);
@@ -289,9 +289,7 @@ VALUE Map_each(VALUE _self) {
289
289
  for (upb_strtable_begin(&it, &self->table);
290
290
  !upb_strtable_done(&it);
291
291
  upb_strtable_next(&it)) {
292
-
293
- VALUE key = table_key_to_ruby(
294
- self, upb_strtable_iter_key(&it), upb_strtable_iter_keylength(&it));
292
+ VALUE key = table_key_to_ruby(self, upb_strtable_iter_key(&it));
295
293
 
296
294
  upb_value v = upb_strtable_iter_value(&it);
297
295
  void* mem = value_memory(&v);
@@ -319,9 +317,7 @@ VALUE Map_keys(VALUE _self) {
319
317
  for (upb_strtable_begin(&it, &self->table);
320
318
  !upb_strtable_done(&it);
321
319
  upb_strtable_next(&it)) {
322
-
323
- VALUE key = table_key_to_ruby(
324
- self, upb_strtable_iter_key(&it), upb_strtable_iter_keylength(&it));
320
+ VALUE key = table_key_to_ruby(self, upb_strtable_iter_key(&it));
325
321
 
326
322
  rb_ary_push(ret, key);
327
323
  }
@@ -526,17 +522,14 @@ VALUE Map_dup(VALUE _self) {
526
522
  for (upb_strtable_begin(&it, &self->table);
527
523
  !upb_strtable_done(&it);
528
524
  upb_strtable_next(&it)) {
529
-
525
+ upb_strview k = upb_strtable_iter_key(&it);
530
526
  upb_value v = upb_strtable_iter_value(&it);
531
527
  void* mem = value_memory(&v);
532
528
  upb_value dup;
533
529
  void* dup_mem = value_memory(&dup);
534
530
  native_slot_dup(self->value_type, dup_mem, mem);
535
531
 
536
- if (!upb_strtable_insert2(&new_self->table,
537
- upb_strtable_iter_key(&it),
538
- upb_strtable_iter_keylength(&it),
539
- dup)) {
532
+ if (!upb_strtable_insert2(&new_self->table, k.data, k.size, dup)) {
540
533
  rb_raise(rb_eRuntimeError, "Error inserting value into new table");
541
534
  }
542
535
  }
@@ -554,7 +547,7 @@ VALUE Map_deep_copy(VALUE _self) {
554
547
  for (upb_strtable_begin(&it, &self->table);
555
548
  !upb_strtable_done(&it);
556
549
  upb_strtable_next(&it)) {
557
-
550
+ upb_strview k = upb_strtable_iter_key(&it);
558
551
  upb_value v = upb_strtable_iter_value(&it);
559
552
  void* mem = value_memory(&v);
560
553
  upb_value dup;
@@ -562,10 +555,7 @@ VALUE Map_deep_copy(VALUE _self) {
562
555
  native_slot_deep_copy(self->value_type, self->value_type_class, dup_mem,
563
556
  mem);
564
557
 
565
- if (!upb_strtable_insert2(&new_self->table,
566
- upb_strtable_iter_key(&it),
567
- upb_strtable_iter_keylength(&it),
568
- dup)) {
558
+ if (!upb_strtable_insert2(&new_self->table, k.data, k.size, dup)) {
569
559
  rb_raise(rb_eRuntimeError, "Error inserting value into new table");
570
560
  }
571
561
  }
@@ -618,16 +608,13 @@ VALUE Map_eq(VALUE _self, VALUE _other) {
618
608
  for (upb_strtable_begin(&it, &self->table);
619
609
  !upb_strtable_done(&it);
620
610
  upb_strtable_next(&it)) {
621
-
611
+ upb_strview k = upb_strtable_iter_key(&it);
622
612
  upb_value v = upb_strtable_iter_value(&it);
623
613
  void* mem = value_memory(&v);
624
614
  upb_value other_v;
625
615
  void* other_mem = value_memory(&other_v);
626
616
 
627
- if (!upb_strtable_lookup2(&other->table,
628
- upb_strtable_iter_key(&it),
629
- upb_strtable_iter_keylength(&it),
630
- &other_v)) {
617
+ if (!upb_strtable_lookup2(&other->table, k.data, k.size, &other_v)) {
631
618
  // Not present in other map.
632
619
  return Qfalse;
633
620
  }
@@ -655,11 +642,9 @@ VALUE Map_hash(VALUE _self) {
655
642
  VALUE hash_sym = rb_intern("hash");
656
643
 
657
644
  upb_strtable_iter it;
658
- for (upb_strtable_begin(&it, &self->table);
659
- !upb_strtable_done(&it);
645
+ for (upb_strtable_begin(&it, &self->table); !upb_strtable_done(&it);
660
646
  upb_strtable_next(&it)) {
661
- VALUE key = table_key_to_ruby(
662
- self, upb_strtable_iter_key(&it), upb_strtable_iter_keylength(&it));
647
+ VALUE key = table_key_to_ruby(self, upb_strtable_iter_key(&it));
663
648
 
664
649
  upb_value v = upb_strtable_iter_value(&it);
665
650
  void* mem = value_memory(&v);
@@ -687,8 +672,7 @@ VALUE Map_to_h(VALUE _self) {
687
672
  for (upb_strtable_begin(&it, &self->table);
688
673
  !upb_strtable_done(&it);
689
674
  upb_strtable_next(&it)) {
690
- VALUE key = table_key_to_ruby(
691
- self, upb_strtable_iter_key(&it), upb_strtable_iter_keylength(&it));
675
+ VALUE key = table_key_to_ruby(self, upb_strtable_iter_key(&it));
692
676
  upb_value v = upb_strtable_iter_value(&it);
693
677
  void* mem = value_memory(&v);
694
678
  VALUE value = native_slot_get(self->value_type,
@@ -720,11 +704,9 @@ VALUE Map_inspect(VALUE _self) {
720
704
  VALUE inspect_sym = rb_intern("inspect");
721
705
 
722
706
  upb_strtable_iter it;
723
- for (upb_strtable_begin(&it, &self->table);
724
- !upb_strtable_done(&it);
707
+ for (upb_strtable_begin(&it, &self->table); !upb_strtable_done(&it);
725
708
  upb_strtable_next(&it)) {
726
- VALUE key = table_key_to_ruby(
727
- self, upb_strtable_iter_key(&it), upb_strtable_iter_keylength(&it));
709
+ VALUE key = table_key_to_ruby(self, upb_strtable_iter_key(&it));
728
710
 
729
711
  upb_value v = upb_strtable_iter_value(&it);
730
712
  void* mem = value_memory(&v);
@@ -785,20 +767,15 @@ VALUE Map_merge_into_self(VALUE _self, VALUE hashmap) {
785
767
  for (upb_strtable_begin(&it, &other->table);
786
768
  !upb_strtable_done(&it);
787
769
  upb_strtable_next(&it)) {
770
+ upb_strview k = upb_strtable_iter_key(&it);
788
771
 
789
772
  // Replace any existing value by issuing a 'remove' operation first.
790
773
  upb_value v;
791
774
  upb_value oldv;
792
- upb_strtable_remove2(&self->table,
793
- upb_strtable_iter_key(&it),
794
- upb_strtable_iter_keylength(&it),
795
- &oldv);
775
+ upb_strtable_remove2(&self->table, k.data, k.size, &oldv);
796
776
 
797
777
  v = upb_strtable_iter_value(&it);
798
- upb_strtable_insert2(&self->table,
799
- upb_strtable_iter_key(&it),
800
- upb_strtable_iter_keylength(&it),
801
- v);
778
+ upb_strtable_insert2(&self->table, k.data, k.size, v);
802
779
  }
803
780
  } else {
804
781
  rb_raise(rb_eArgError, "Unknown type merging into Map");
@@ -822,10 +799,7 @@ bool Map_done(Map_iter* iter) {
822
799
  }
823
800
 
824
801
  VALUE Map_iter_key(Map_iter* iter) {
825
- return table_key_to_ruby(
826
- iter->self,
827
- upb_strtable_iter_key(&iter->it),
828
- upb_strtable_iter_keylength(&iter->it));
802
+ return table_key_to_ruby(iter->self, upb_strtable_iter_key(&iter->it));
829
803
  }
830
804
 
831
805
  VALUE Map_iter_value(Map_iter* iter) {