| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 } | 770 } |
| 771 | 771 |
| 772 void RepeatedImmutablePrimitiveFieldGenerator:: | 772 void RepeatedImmutablePrimitiveFieldGenerator:: |
| 773 GenerateSerializationCode(io::Printer* printer) const { | 773 GenerateSerializationCode(io::Printer* printer) const { |
| 774 if (descriptor_->is_packed()) { | 774 if (descriptor_->is_packed()) { |
| 775 // We invoke getSerializedSize in writeTo for messages that have packed | 775 // We invoke getSerializedSize in writeTo for messages that have packed |
| 776 // fields in ImmutableMessageGenerator::GenerateMessageSerializationMethods. | 776 // fields in ImmutableMessageGenerator::GenerateMessageSerializationMethods. |
| 777 // That makes it safe to rely on the memoized size here. | 777 // That makes it safe to rely on the memoized size here. |
| 778 printer->Print(variables_, | 778 printer->Print(variables_, |
| 779 "if (get$capitalized_name$List().size() > 0) {\n" | 779 "if (get$capitalized_name$List().size() > 0) {\n" |
| 780 " output.writeRawVarint32($tag$);\n" | 780 " output.writeUInt32NoTag($tag$);\n" |
| 781 " output.writeRawVarint32($name$MemoizedSerializedSize);\n" | 781 " output.writeUInt32NoTag($name$MemoizedSerializedSize);\n" |
| 782 "}\n" | 782 "}\n" |
| 783 "for (int i = 0; i < $name$_.size(); i++) {\n" | 783 "for (int i = 0; i < $name$_.size(); i++) {\n" |
| 784 " output.write$capitalized_type$NoTag($name$_.get(i));\n" | 784 " output.write$capitalized_type$NoTag($name$_.get(i));\n" |
| 785 "}\n"); | 785 "}\n"); |
| 786 } else { | 786 } else { |
| 787 printer->Print(variables_, | 787 printer->Print(variables_, |
| 788 "for (int i = 0; i < $name$_.size(); i++) {\n" | 788 "for (int i = 0; i < $name$_.size(); i++) {\n" |
| 789 " output.write$capitalized_type$($number$, $name$_.get(i));\n" | 789 " output.write$capitalized_type$($number$, $name$_.get(i));\n" |
| 790 "}\n"); | 790 "}\n"); |
| 791 } | 791 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 } | 851 } |
| 852 | 852 |
| 853 string RepeatedImmutablePrimitiveFieldGenerator::GetBoxedType() const { | 853 string RepeatedImmutablePrimitiveFieldGenerator::GetBoxedType() const { |
| 854 return BoxedPrimitiveTypeName(GetJavaType(descriptor_)); | 854 return BoxedPrimitiveTypeName(GetJavaType(descriptor_)); |
| 855 } | 855 } |
| 856 | 856 |
| 857 } // namespace java | 857 } // namespace java |
| 858 } // namespace compiler | 858 } // namespace compiler |
| 859 } // namespace protobuf | 859 } // namespace protobuf |
| 860 } // namespace google | 860 } // namespace google |
| OLD | NEW |