aboutsummaryrefslogtreecommitdiff
path: root/ruby/ext/google/protobuf_c/map.c
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2017-08-30 11:16:57 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2017-08-30 11:38:09 -0700
commitf55c6ec24f8ac51c80d40f06732537a2d2aa3ab1 (patch)
tree2c4ac5adc8fa043b6838d36c01f0eb3cf05232cb /ruby/ext/google/protobuf_c/map.c
parentd6152dd51c833bae79208ee8c03bd6a1d21fe632 (diff)
downloadprotobuf-f55c6ec24f8ac51c80d40f06732537a2d2aa3ab1.tar.gz
protobuf-f55c6ec24f8ac51c80d40f06732537a2d2aa3ab1.tar.bz2
protobuf-f55c6ec24f8ac51c80d40f06732537a2d2aa3ab1.zip
Storing the frame on the map means we don't need the array
Diffstat (limited to 'ruby/ext/google/protobuf_c/map.c')
-rw-r--r--ruby/ext/google/protobuf_c/map.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/ruby/ext/google/protobuf_c/map.c b/ruby/ext/google/protobuf_c/map.c
index 0787f6d5..26e22dc7 100644
--- a/ruby/ext/google/protobuf_c/map.c
+++ b/ruby/ext/google/protobuf_c/map.c
@@ -146,7 +146,7 @@ void Map_mark(void* _self) {
Map* self = _self;
rb_gc_mark(self->value_type_class);
- rb_gc_mark(self->parse_frames);
+ rb_gc_mark(self->parse_frame);
if (self->value_type == UPB_TYPE_STRING ||
self->value_type == UPB_TYPE_BYTES ||
@@ -175,14 +175,10 @@ VALUE Map_alloc(VALUE klass) {
return TypedData_Wrap_Struct(klass, &Map_type, self);
}
-VALUE Map_push_frame(VALUE map, VALUE val) {
+VALUE Map_set_frame(VALUE map, VALUE val) {
Map* self = ruby_to_Map(map);
- return rb_ary_push(self->parse_frames, val);
-}
-
-VALUE Map_pop_frame(VALUE map) {
- Map* self = ruby_to_Map(map);
- return rb_ary_pop(self->parse_frames);
+ self->parse_frame = val;
+ return val;
}
static bool needs_typeclass(upb_fieldtype_t type) {
@@ -238,7 +234,7 @@ VALUE Map_init(int argc, VALUE* argv, VALUE _self) {
self->key_type = ruby_to_fieldtype(argv[0]);
self->value_type = ruby_to_fieldtype(argv[1]);
- self->parse_frames = rb_ary_new();
+ self->parse_frame = Qnil;
// Check that the key type is an allowed type.
switch (self->key_type) {