Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
f55c6ec2
Unverified
Commit
f55c6ec2
authored
Aug 30, 2017
by
Aaron Patterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Storing the frame on the map means we don't need the array
parent
d6152dd5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
14 deletions
+9
-14
encode_decode.c
ruby/ext/google/protobuf_c/encode_decode.c
+2
-2
map.c
ruby/ext/google/protobuf_c/map.c
+5
-9
protobuf.h
ruby/ext/google/protobuf_c/protobuf.h
+2
-3
No files found.
ruby/ext/google/protobuf_c/encode_decode.c
View file @
f55c6ec2
...
...
@@ -288,7 +288,7 @@ static map_parse_frame_t* map_push_frame(VALUE map,
native_slot_init
(
handlerdata
->
key_field_type
,
&
frame
->
key_storage
);
native_slot_init
(
handlerdata
->
value_field_type
,
&
frame
->
value_storage
);
Map_
push
_frame
(
map
,
Map_
set
_frame
(
map
,
TypedData_Wrap_Struct
(
rb_cObject
,
&
MapParseFrame_type
,
frame
));
return
frame
;
...
...
@@ -327,7 +327,7 @@ static bool endmap_handler(void *closure, const void *hd, upb_status* s) {
&
frame
->
value_storage
);
Map_index_set
(
frame
->
map
,
key
,
value
);
Map_
pop_frame
(
frame
->
map
);
Map_
set_frame
(
frame
->
map
,
Qnil
);
return
true
;
}
...
...
ruby/ext/google/protobuf_c/map.c
View file @
f55c6ec2
...
...
@@ -146,7 +146,7 @@ void Map_mark(void* _self) {
Map
*
self
=
_self
;
rb_gc_mark
(
self
->
value_type_class
);
rb_gc_mark
(
self
->
parse_frame
s
);
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_frame
s
=
rb_ary_new
()
;
self
->
parse_frame
=
Qnil
;
// Check that the key type is an allowed type.
switch
(
self
->
key_type
)
{
...
...
ruby/ext/google/protobuf_c/protobuf.h
View file @
f55c6ec2
...
...
@@ -395,7 +395,7 @@ typedef struct {
upb_fieldtype_t
key_type
;
upb_fieldtype_t
value_type
;
VALUE
value_type_class
;
VALUE
parse_frame
s
;
VALUE
parse_frame
;
upb_strtable
table
;
}
Map
;
...
...
@@ -404,8 +404,7 @@ void Map_free(void* self);
VALUE
Map_alloc
(
VALUE
klass
);
VALUE
Map_init
(
int
argc
,
VALUE
*
argv
,
VALUE
self
);
void
Map_register
(
VALUE
module
);
VALUE
Map_push_frame
(
VALUE
self
,
VALUE
val
);
VALUE
Map_pop_frame
(
VALUE
self
);
VALUE
Map_set_frame
(
VALUE
self
,
VALUE
val
);
extern
const
rb_data_type_t
Map_type
;
extern
VALUE
cMap
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment