Reserve vector capacity prior to calling `push_back()` in a loop.

PiperOrigin-RevId: 435111851
pull/13171/head
Protobuf Team 3 years ago committed by Copybara-Service
parent 027129bf0f
commit b0f55f0879
  1. 1
      upbc/protoc-gen-upb.cc

@ -120,6 +120,7 @@ std::vector<const protobuf::EnumDescriptor*> SortedEnums(
std::vector<int32_t> SortedUniqueEnumNumbers(
const protobuf::EnumDescriptor* e) {
std::vector<int32_t> values;
values.reserve(e->value_count());
for (int i = 0; i < e->value_count(); i++) {
values.push_back(e->value(i)->number());
}

Loading…
Cancel
Save