Commit 8af35f28 authored by Chris Kennelly's avatar Chris Kennelly

Keep loop bounds in a local variable for string fields.

parent a6c30d97
...@@ -969,7 +969,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const { ...@@ -969,7 +969,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
void RepeatedStringFieldGenerator:: void RepeatedStringFieldGenerator::
GenerateSerializeWithCachedSizes(io::Printer* printer) const { GenerateSerializeWithCachedSizes(io::Printer* printer) const {
printer->Print(variables_, printer->Print(variables_,
"for (int i = 0; i < this->$name$_size(); i++) {\n"); "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
printer->Indent(); printer->Indent();
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
...@@ -986,7 +986,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const { ...@@ -986,7 +986,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
void RepeatedStringFieldGenerator:: void RepeatedStringFieldGenerator::
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const { GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
printer->Print(variables_, printer->Print(variables_,
"for (int i = 0; i < this->$name$_size(); i++) {\n"); "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n");
printer->Indent(); printer->Indent();
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString( GenerateUtf8CheckCodeForString(
...@@ -1005,7 +1005,7 @@ GenerateByteSize(io::Printer* printer) const { ...@@ -1005,7 +1005,7 @@ GenerateByteSize(io::Printer* printer) const {
printer->Print(variables_, printer->Print(variables_,
"total_size += $tag_size$ *\n" "total_size += $tag_size$ *\n"
" ::google::protobuf::internal::FromIntSize(this->$name$_size());\n" " ::google::protobuf::internal::FromIntSize(this->$name$_size());\n"
"for (int i = 0; i < this->$name$_size(); i++) {\n" "for (int i = 0, n = this->$name$_size(); i < n; i++) {\n"
" total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n" " total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\n"
" this->$name$(i));\n" " this->$name$(i));\n"
"}\n"); "}\n");
......
...@@ -887,7 +887,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( ...@@ -887,7 +887,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const { ::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorRequest) // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorRequest)
// repeated string file_to_generate = 1; // repeated string file_to_generate = 1;
for (int i = 0; i < this->file_to_generate_size(); i++) { for (int i = 0, n = this->file_to_generate_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->file_to_generate(i).data(), this->file_to_generate(i).length(), this->file_to_generate(i).data(), this->file_to_generate(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
...@@ -930,7 +930,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes( ...@@ -930,7 +930,7 @@ void CodeGeneratorRequest::SerializeWithCachedSizes(
(void)deterministic; // Unused (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest) // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest)
// repeated string file_to_generate = 1; // repeated string file_to_generate = 1;
for (int i = 0; i < this->file_to_generate_size(); i++) { for (int i = 0, n = this->file_to_generate_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->file_to_generate(i).data(), this->file_to_generate(i).length(), this->file_to_generate(i).data(), this->file_to_generate(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
...@@ -984,7 +984,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const { ...@@ -984,7 +984,7 @@ size_t CodeGeneratorRequest::ByteSizeLong() const {
// repeated string file_to_generate = 1; // repeated string file_to_generate = 1;
total_size += 1 * total_size += 1 *
::google::protobuf::internal::FromIntSize(this->file_to_generate_size()); ::google::protobuf::internal::FromIntSize(this->file_to_generate_size());
for (int i = 0; i < this->file_to_generate_size(); i++) { for (int i = 0, n = this->file_to_generate_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize( total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->file_to_generate(i)); this->file_to_generate(i));
} }
......
...@@ -1576,7 +1576,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( ...@@ -1576,7 +1576,7 @@ void FileDescriptorProto::SerializeWithCachedSizes(
} }
// repeated string dependency = 3; // repeated string dependency = 3;
for (int i = 0; i < this->dependency_size(); i++) { for (int i = 0, n = this->dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->dependency(i).data(), this->dependency(i).length(), this->dependency(i).data(), this->dependency(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
...@@ -1677,7 +1677,7 @@ void FileDescriptorProto::SerializeWithCachedSizes( ...@@ -1677,7 +1677,7 @@ void FileDescriptorProto::SerializeWithCachedSizes(
} }
// repeated string dependency = 3; // repeated string dependency = 3;
for (int i = 0; i < this->dependency_size(); i++) { for (int i = 0, n = this->dependency_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->dependency(i).data(), this->dependency(i).length(), this->dependency(i).data(), this->dependency(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
...@@ -1771,7 +1771,7 @@ size_t FileDescriptorProto::ByteSizeLong() const { ...@@ -1771,7 +1771,7 @@ size_t FileDescriptorProto::ByteSizeLong() const {
// repeated string dependency = 3; // repeated string dependency = 3;
total_size += 1 * total_size += 1 *
::google::protobuf::internal::FromIntSize(this->dependency_size()); ::google::protobuf::internal::FromIntSize(this->dependency_size());
for (int i = 0; i < this->dependency_size(); i++) { for (int i = 0, n = this->dependency_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize( total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->dependency(i)); this->dependency(i));
} }
...@@ -3511,7 +3511,7 @@ void DescriptorProto::SerializeWithCachedSizes( ...@@ -3511,7 +3511,7 @@ void DescriptorProto::SerializeWithCachedSizes(
} }
// repeated string reserved_name = 10; // repeated string reserved_name = 10;
for (int i = 0; i < this->reserved_name_size(); i++) { for (int i = 0, n = this->reserved_name_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->reserved_name(i).data(), this->reserved_name(i).length(), this->reserved_name(i).data(), this->reserved_name(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
...@@ -3599,7 +3599,7 @@ void DescriptorProto::SerializeWithCachedSizes( ...@@ -3599,7 +3599,7 @@ void DescriptorProto::SerializeWithCachedSizes(
} }
// repeated string reserved_name = 10; // repeated string reserved_name = 10;
for (int i = 0; i < this->reserved_name_size(); i++) { for (int i = 0, n = this->reserved_name_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->reserved_name(i).data(), this->reserved_name(i).length(), this->reserved_name(i).data(), this->reserved_name(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
...@@ -3705,7 +3705,7 @@ size_t DescriptorProto::ByteSizeLong() const { ...@@ -3705,7 +3705,7 @@ size_t DescriptorProto::ByteSizeLong() const {
// repeated string reserved_name = 10; // repeated string reserved_name = 10;
total_size += 1 * total_size += 1 *
::google::protobuf::internal::FromIntSize(this->reserved_name_size()); ::google::protobuf::internal::FromIntSize(this->reserved_name_size());
for (int i = 0; i < this->reserved_name_size(); i++) { for (int i = 0, n = this->reserved_name_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize( total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->reserved_name(i)); this->reserved_name(i));
} }
...@@ -14137,7 +14137,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( ...@@ -14137,7 +14137,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
} }
// repeated string leading_detached_comments = 6; // repeated string leading_detached_comments = 6;
for (int i = 0; i < this->leading_detached_comments_size(); i++) { for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(), this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
...@@ -14208,7 +14208,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes( ...@@ -14208,7 +14208,7 @@ void SourceCodeInfo_Location::SerializeWithCachedSizes(
} }
// repeated string leading_detached_comments = 6; // repeated string leading_detached_comments = 6;
for (int i = 0; i < this->leading_detached_comments_size(); i++) { for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) {
::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(), this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(),
::google::protobuf::internal::WireFormat::SERIALIZE, ::google::protobuf::internal::WireFormat::SERIALIZE,
...@@ -14267,7 +14267,7 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const { ...@@ -14267,7 +14267,7 @@ size_t SourceCodeInfo_Location::ByteSizeLong() const {
// repeated string leading_detached_comments = 6; // repeated string leading_detached_comments = 6;
total_size += 1 * total_size += 1 *
::google::protobuf::internal::FromIntSize(this->leading_detached_comments_size()); ::google::protobuf::internal::FromIntSize(this->leading_detached_comments_size());
for (int i = 0; i < this->leading_detached_comments_size(); i++) { for (int i = 0, n = this->leading_detached_comments_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize( total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->leading_detached_comments(i)); this->leading_detached_comments(i));
} }
......
...@@ -232,7 +232,7 @@ void FieldMask::SerializeWithCachedSizes( ...@@ -232,7 +232,7 @@ void FieldMask::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const { ::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.protobuf.FieldMask) // @@protoc_insertion_point(serialize_start:google.protobuf.FieldMask)
// repeated string paths = 1; // repeated string paths = 1;
for (int i = 0; i < this->paths_size(); i++) { for (int i = 0, n = this->paths_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->paths(i).data(), this->paths(i).length(), this->paths(i).data(), this->paths(i).length(),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
...@@ -249,7 +249,7 @@ void FieldMask::SerializeWithCachedSizes( ...@@ -249,7 +249,7 @@ void FieldMask::SerializeWithCachedSizes(
(void)deterministic; // Unused (void)deterministic; // Unused
// @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask) // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask)
// repeated string paths = 1; // repeated string paths = 1;
for (int i = 0; i < this->paths_size(); i++) { for (int i = 0, n = this->paths_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->paths(i).data(), this->paths(i).length(), this->paths(i).data(), this->paths(i).length(),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
...@@ -269,7 +269,7 @@ size_t FieldMask::ByteSizeLong() const { ...@@ -269,7 +269,7 @@ size_t FieldMask::ByteSizeLong() const {
// repeated string paths = 1; // repeated string paths = 1;
total_size += 1 * total_size += 1 *
::google::protobuf::internal::FromIntSize(this->paths_size()); ::google::protobuf::internal::FromIntSize(this->paths_size());
for (int i = 0; i < this->paths_size(); i++) { for (int i = 0, n = this->paths_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize( total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->paths(i)); this->paths(i));
} }
......
...@@ -613,7 +613,7 @@ void Type::SerializeWithCachedSizes( ...@@ -613,7 +613,7 @@ void Type::SerializeWithCachedSizes(
} }
// repeated string oneofs = 3; // repeated string oneofs = 3;
for (int i = 0; i < this->oneofs_size(); i++) { for (int i = 0, n = this->oneofs_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->oneofs(i).data(), this->oneofs(i).length(), this->oneofs(i).data(), this->oneofs(i).length(),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
...@@ -666,7 +666,7 @@ void Type::SerializeWithCachedSizes( ...@@ -666,7 +666,7 @@ void Type::SerializeWithCachedSizes(
} }
// repeated string oneofs = 3; // repeated string oneofs = 3;
for (int i = 0; i < this->oneofs_size(); i++) { for (int i = 0, n = this->oneofs_size(); i < n; i++) {
::google::protobuf::internal::WireFormatLite::VerifyUtf8String( ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
this->oneofs(i).data(), this->oneofs(i).length(), this->oneofs(i).data(), this->oneofs(i).length(),
::google::protobuf::internal::WireFormatLite::SERIALIZE, ::google::protobuf::internal::WireFormatLite::SERIALIZE,
...@@ -717,7 +717,7 @@ size_t Type::ByteSizeLong() const { ...@@ -717,7 +717,7 @@ size_t Type::ByteSizeLong() const {
// repeated string oneofs = 3; // repeated string oneofs = 3;
total_size += 1 * total_size += 1 *
::google::protobuf::internal::FromIntSize(this->oneofs_size()); ::google::protobuf::internal::FromIntSize(this->oneofs_size());
for (int i = 0; i < this->oneofs_size(); i++) { for (int i = 0, n = this->oneofs_size(); i < n; i++) {
total_size += ::google::protobuf::internal::WireFormatLite::StringSize( total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
this->oneofs(i)); this->oneofs(i));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment