mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-27 22:01:02 +08:00
optimziation
git-svn-id: https://protobuf-c.googlecode.com/svn/trunk@206 00440858-1255-0410-a3e6-75ea37f81c3a
This commit is contained in:
parent
10d3195d3a
commit
3a97180293
@ -4,6 +4,8 @@
|
||||
- Add --disable-protoc to only build libprotobuf-c (daveb)
|
||||
- Bug fixes for protobuf_c_enum_descriptor_get_value_by_name()
|
||||
and protobuf_c_service_descriptor_get_method_by_name()
|
||||
- if descriptor->message_init != NULL, use it from unpack()
|
||||
as an optimization (daveb)
|
||||
|
||||
0.12:
|
||||
- for field names which are reserved words, use the real name
|
||||
|
@ -1448,11 +1448,17 @@ parse_member (ScannedMember *scanned_member,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
setup_default_values (ProtobufCMessage *message)
|
||||
|
||||
/* TODO: expose/use this function if desc->message_init==NULL
|
||||
(which occurs for old code, and may be useful for certain
|
||||
programatic techniques for generating descriptors). */
|
||||
void
|
||||
protobuf_c_message_init_generic (const ProtobufCMessageDescriptor *desc,
|
||||
ProtobufCMessage *message)
|
||||
{
|
||||
const ProtobufCMessageDescriptor *desc = message->descriptor;
|
||||
unsigned i;
|
||||
memset (message, 0, desc->sizeof_message);
|
||||
message->descriptor = desc;
|
||||
for (i = 0; i < desc->n_fields; i++)
|
||||
if (desc->fields[i].default_value != NULL
|
||||
&& desc->fields[i].label != PROTOBUF_C_LABEL_REPEATED)
|
||||
@ -1548,10 +1554,15 @@ protobuf_c_message_unpack (const ProtobufCMessageDescriptor *desc,
|
||||
DO_ALLOC (rv, allocator, desc->sizeof_message, return NULL);
|
||||
scanned_member_slabs[0] = first_member_slab;
|
||||
|
||||
memset (rv, 0, desc->sizeof_message);
|
||||
rv->descriptor = desc;
|
||||
|
||||
setup_default_values (rv);
|
||||
/* Generated code always defines "message_init".
|
||||
However, we provide a fallback for (1) users of old protobuf-c
|
||||
generated-code that do not provide the function,
|
||||
and (2) descriptors constructed from some other source
|
||||
(most likely, direct construction from the .proto file) */
|
||||
if (desc->message_init != NULL)
|
||||
protobuf_c_message_init (desc, rv);
|
||||
else
|
||||
protobuf_c_message_init_generic (desc, rv);
|
||||
|
||||
while (rem > 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user