These unused variables are still being generated by protobuf-2.5.0.
Attached is a diff that conditionally suppresses their generation.
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
diff -u protobuf-2.5.0/src/google/protobuf/compiler/java/java_message.cc protobuf-2.5.0/src/google/protobuf/compiler/java/java_message.cc.orig
--- protobuf-2.5.0/src/google/protobuf/compiler/java/java_message.cc 2013-03-25 13:24:04.000000000 -0700
+++ protobuf-2.5.0/src/google/protobuf/compiler/java/java_message.cc.orig 2013-02-26 09:56:40.000000000 -0800
@@ -907,22 +907,16 @@
// code does.
int totalBuilderBits = 0;
int totalMessageBits = 0;
- int numReqOpt = 0;
for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* dfield = descriptor_->field(i);
- const FieldGenerator& field = field_generators_.get(dfield);
+ const FieldGenerator& field = field_generators_.get(descriptor_->field(i));
totalBuilderBits += field.GetNumBitsForBuilder();
totalMessageBits += field.GetNumBitsForMessage();
- if (dfield->is_required() || dfield->is_optional())
- numReqOpt++;
}
+ int totalBuilderInts = (totalBuilderBits + 31) / 32;
int totalMessageInts = (totalMessageBits + 31) / 32;
- if (numReqOpt /* != 0 */) {
- int totalBuilderInts = (totalBuilderBits + 31) / 32;
- for (int i = 0; i < totalBuilderInts; i++) {
- printer->Print("int from_$bit_field_name$ = $bit_field_name$;\n",
- "bit_field_name", GetBitFieldName(i));
- }
+ for (int i = 0; i < totalBuilderInts; i++) {
+ printer->Print("int from_$bit_field_name$ = $bit_field_name$;\n",
+ "bit_field_name", GetBitFieldName(i));
}
for (int i = 0; i < totalMessageInts; i++) {
printer->Print("int to_$bit_field_name$ = 0;\n",
@@ -1265,20 +1259,14 @@
// Use builder bits to track mutable repeated fields.
int totalBuilderBits = 0;
- int numRepeatedFields = 0;
for (int i = 0; i < descriptor_->field_count(); i++) {
- const FieldDescriptor* dfield = descriptor_->field(i);
- const FieldGenerator& field = field_generators_.get(dfield);
+ const FieldGenerator& field = field_generators_.get(descriptor_->field(i));
totalBuilderBits += field.GetNumBitsForBuilder();
- if (dfield->is_repeated())
- numRepeatedFields++;
}
- if (numRepeatedFields /* > 0 */) {
- int totalBuilderInts = (totalBuilderBits + 31) / 32;
- for (int i = 0; i < totalBuilderInts; i++) {
- printer->Print("int mutable_$bit_field_name$ = 0;\n",
- "bit_field_name", GetBitFieldName(i));
- }
+ int totalBuilderInts = (totalBuilderBits + 31) / 32;
+ for (int i = 0; i < totalBuilderInts; i++) {
+ printer->Print("int mutable_$bit_field_name$ = 0;\n",
+ "bit_field_name", GetBitFieldName(i));
}
if (HasUnknownFields(descriptor_)) {
Diff finished. Mon Apr 29 18:04:51 2013