aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
diff options
context:
space:
mode:
authorGravatar Chris Kennelly <ckennelly@google.com>2017-01-11 15:59:46 -0800
committerGravatar Chris Kennelly <ckennelly@google.com>2017-02-15 11:40:27 -0800
commita6c30d97054bbd6d591e471da112c5dfef501bb4 (patch)
tree4956c59fb7b5678800ecd61e731e3dcdb01246ed /src/google/protobuf/compiler/cpp/cpp_enum_field.cc
parent9db5b11c9cf2922435b53495b9c1e114525f0428 (diff)
Keep loop bounds in a local variable.
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_enum_field.cc')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum_field.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index 44a86fc8..e4b17a98 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -436,7 +436,7 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
"}\n");
}
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");
if (descriptor_->is_packed()) {
printer->Print(variables_,
" ::google::protobuf::internal::WireFormatLite::WriteEnumNoTag(\n"
@@ -464,7 +464,7 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
"}\n");
}
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");
if (descriptor_->is_packed()) {
printer->Print(variables_,
" target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n"