| Index: third_party/protobuf/src/google/protobuf/generated_message_reflection.cc | 
| diff --git a/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc b/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc | 
| index 2313181cc995220fe39ce23236e365b467e05276..6f418433dfd82d2c660ead85b2141b46ba184be9 100644 | 
| --- a/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc | 
| +++ b/third_party/protobuf/src/google/protobuf/generated_message_reflection.cc | 
| @@ -173,62 +173,43 @@ static void ReportReflectionUsageEnumTypeError( | 
| // =================================================================== | 
|  | 
| GeneratedMessageReflection::GeneratedMessageReflection( | 
| -    const Descriptor* descriptor, | 
| -    const Message* default_instance, | 
| -    const int offsets[], | 
| -    int has_bits_offset, | 
| -    int unknown_fields_offset, | 
| -    int extensions_offset, | 
| -    const DescriptorPool* descriptor_pool, | 
| -    MessageFactory* factory, | 
| -    int object_size, | 
| -    int arena_offset, | 
| -    int is_default_instance_offset) | 
| -  : descriptor_       (descriptor), | 
| -    default_instance_ (default_instance), | 
| -    offsets_          (offsets), | 
| -    has_bits_offset_  (has_bits_offset), | 
| -    unknown_fields_offset_(unknown_fields_offset), | 
| -    extensions_offset_(extensions_offset), | 
| -    arena_offset_     (arena_offset), | 
| -    is_default_instance_offset_(is_default_instance_offset), | 
| -    object_size_      (object_size), | 
| -    descriptor_pool_  ((descriptor_pool == NULL) ? | 
| -                         DescriptorPool::generated_pool() : | 
| -                         descriptor_pool), | 
| -    message_factory_  (factory) { | 
| -} | 
| +    const Descriptor* descriptor, const Message* default_instance, | 
| +    const int offsets[], int has_bits_offset, int unknown_fields_offset, | 
| +    int extensions_offset, const DescriptorPool* descriptor_pool, | 
| +    MessageFactory* factory, int object_size, int arena_offset) | 
| +    : descriptor_(descriptor), | 
| +      default_instance_(default_instance), | 
| +      offsets_(offsets), | 
| +      has_bits_offset_(has_bits_offset), | 
| +      unknown_fields_offset_(unknown_fields_offset), | 
| +      extensions_offset_(extensions_offset), | 
| +      arena_offset_(arena_offset), | 
| +      object_size_(object_size), | 
| +      descriptor_pool_((descriptor_pool == NULL) | 
| +                           ? DescriptorPool::generated_pool() | 
| +                           : descriptor_pool), | 
| +      message_factory_(factory) {} | 
|  | 
| GeneratedMessageReflection::GeneratedMessageReflection( | 
| -    const Descriptor* descriptor, | 
| -    const Message* default_instance, | 
| -    const int offsets[], | 
| -    int has_bits_offset, | 
| -    int unknown_fields_offset, | 
| -    int extensions_offset, | 
| -    const void* default_oneof_instance, | 
| -    int oneof_case_offset, | 
| -    const DescriptorPool* descriptor_pool, | 
| -    MessageFactory* factory, | 
| -    int object_size, | 
| -    int arena_offset, | 
| -    int is_default_instance_offset) | 
| -  : descriptor_       (descriptor), | 
| -    default_instance_ (default_instance), | 
| -    default_oneof_instance_ (default_oneof_instance), | 
| -    offsets_          (offsets), | 
| -    has_bits_offset_  (has_bits_offset), | 
| -    oneof_case_offset_(oneof_case_offset), | 
| -    unknown_fields_offset_(unknown_fields_offset), | 
| -    extensions_offset_(extensions_offset), | 
| -    arena_offset_     (arena_offset), | 
| -    is_default_instance_offset_(is_default_instance_offset), | 
| -    object_size_      (object_size), | 
| -    descriptor_pool_  ((descriptor_pool == NULL) ? | 
| -                         DescriptorPool::generated_pool() : | 
| -                         descriptor_pool), | 
| -    message_factory_  (factory) { | 
| -} | 
| +    const Descriptor* descriptor, const Message* default_instance, | 
| +    const int offsets[], int has_bits_offset, int unknown_fields_offset, | 
| +    int extensions_offset, const void* default_oneof_instance, | 
| +    int oneof_case_offset, const DescriptorPool* descriptor_pool, | 
| +    MessageFactory* factory, int object_size, int arena_offset) | 
| +    : descriptor_(descriptor), | 
| +      default_instance_(default_instance), | 
| +      default_oneof_instance_(default_oneof_instance), | 
| +      offsets_(offsets), | 
| +      has_bits_offset_(has_bits_offset), | 
| +      oneof_case_offset_(oneof_case_offset), | 
| +      unknown_fields_offset_(unknown_fields_offset), | 
| +      extensions_offset_(extensions_offset), | 
| +      arena_offset_(arena_offset), | 
| +      object_size_(object_size), | 
| +      descriptor_pool_((descriptor_pool == NULL) | 
| +                           ? DescriptorPool::generated_pool() | 
| +                           : descriptor_pool), | 
| +      message_factory_(factory) {} | 
|  | 
| GeneratedMessageReflection::~GeneratedMessageReflection() {} | 
|  | 
| @@ -1026,6 +1007,11 @@ struct FieldNumberSorter { | 
| return left->number() < right->number(); | 
| } | 
| }; | 
| + | 
| +inline bool IsIndexInHasBitSet(const uint32* has_bit_set, uint32 index) { | 
| +  return ((has_bit_set[index / 32] >> (index % 32)) & static_cast<uint32>(1)) | 
| +      != 0; | 
| +} | 
| }  // namespace | 
|  | 
| void GeneratedMessageReflection::ListFields( | 
| @@ -1036,6 +1022,12 @@ void GeneratedMessageReflection::ListFields( | 
| // Optimization:  The default instance never has any fields set. | 
| if (&message == default_instance_) return; | 
|  | 
| +  // Optimization: Avoid calling GetHasBits() and HasOneofField() many times | 
| +  // within the field loop. | 
| +  const uint32* const has_bits = GetHasBits(message); | 
| +  const uint32* const oneof_case_array = reinterpret_cast<const uint32*>( | 
| +      reinterpret_cast<const uint8*>(&message) + oneof_case_offset_); | 
| + | 
| output->reserve(descriptor_->field_count()); | 
| for (int i = 0; i < descriptor_->field_count(); i++) { | 
| const FieldDescriptor* field = descriptor_->field(i); | 
| @@ -1044,11 +1036,18 @@ void GeneratedMessageReflection::ListFields( | 
| output->push_back(field); | 
| } | 
| } else { | 
| -      if (field->containing_oneof()) { | 
| -        if (HasOneofField(message, field)) { | 
| +      const OneofDescriptor* containing_oneof = field->containing_oneof(); | 
| +      if (containing_oneof) { | 
| +        // Equivalent to: HasOneofField(message, field) | 
| +        if (oneof_case_array[containing_oneof->index()] == field->number()) { | 
| output->push_back(field); | 
| } | 
| -      } else if (HasBit(message, field)) { | 
| +      } else if (has_bits) { | 
| +        // Equivalent to: HasBit(message, field) | 
| +        if (IsIndexInHasBitSet(has_bits, i)) { | 
| +          output->push_back(field); | 
| +        } | 
| +      } else if (HasBit(message, field)) {  // Fall back on proto3-style HasBit. | 
| output->push_back(field); | 
| } | 
| } | 
| @@ -1579,7 +1578,8 @@ Message* GeneratedMessageReflection::UnsafeArenaReleaseMessage( | 
|  | 
| if (field->is_extension()) { | 
| return static_cast<Message*>( | 
| -        MutableExtensionSet(message)->ReleaseMessage(field, factory)); | 
| +        MutableExtensionSet(message)->UnsafeArenaReleaseMessage(field, | 
| +                                                                factory)); | 
| } else { | 
| ClearBit(message, field); | 
| if (field->containing_oneof()) { | 
| @@ -2000,12 +2000,7 @@ GeneratedMessageReflection::MutableInternalMetadataWithArena( | 
| inline bool | 
| GeneratedMessageReflection::GetIsDefaultInstance( | 
| const Message& message) const { | 
| -  if (is_default_instance_offset_ == kHasNoDefaultInstanceField) { | 
| -    return false; | 
| -  } | 
| -  const void* ptr = reinterpret_cast<const uint8*>(&message) + | 
| -      is_default_instance_offset_; | 
| -  return *reinterpret_cast<const bool*>(ptr); | 
| +  return &message == default_instance_; | 
| } | 
|  | 
| // Simple accessors for manipulating has_bits_. | 
| @@ -2062,8 +2057,7 @@ inline bool GeneratedMessageReflection::HasBit( | 
| } | 
| } | 
| } | 
| -  return GetHasBits(message)[field->index() / 32] & | 
| -    (1 << (field->index() % 32)); | 
| +  return IsIndexInHasBitSet(GetHasBits(message), field->index()); | 
| } | 
|  | 
| inline void GeneratedMessageReflection::SetBit( | 
| @@ -2071,7 +2065,9 @@ inline void GeneratedMessageReflection::SetBit( | 
| if (has_bits_offset_ == -1) { | 
| return; | 
| } | 
| -  MutableHasBits(message)[field->index() / 32] |= (1 << (field->index() % 32)); | 
| +  const uint32 index = static_cast<uint32>(field->index()); | 
| +  MutableHasBits(message)[index / 32] |= | 
| +      (static_cast<uint32>(1) << (index % 32)); | 
| } | 
|  | 
| inline void GeneratedMessageReflection::ClearBit( | 
| @@ -2079,7 +2075,9 @@ inline void GeneratedMessageReflection::ClearBit( | 
| if (has_bits_offset_ == -1) { | 
| return; | 
| } | 
| -  MutableHasBits(message)[field->index() / 32] &= ~(1 << (field->index() % 32)); | 
| +  const uint32 index = static_cast<uint32>(field->index()); | 
| +  MutableHasBits(message)[index / 32] &= | 
| +      ~(static_cast<uint32>(1) << (index % 32)); | 
| } | 
|  | 
| inline void GeneratedMessageReflection::SwapBit( | 
| @@ -2125,7 +2123,7 @@ inline void GeneratedMessageReflection::ClearOneofField( | 
| inline void GeneratedMessageReflection::ClearOneof( | 
| Message* message, const OneofDescriptor* oneof_descriptor) const { | 
| // TODO(jieluo): Consider to cache the unused object instead of deleting | 
| -  // it. It will be much faster if an aplication switches a lot from | 
| +  // it. It will be much faster if an application switches a lot from | 
| // a few oneof fields.  Time/space tradeoff | 
| uint32 oneof_case = GetOneofCase(*message, oneof_descriptor); | 
| if (oneof_case > 0) { | 
| @@ -2274,19 +2272,11 @@ GeneratedMessageReflection::NewGeneratedMessageReflection( | 
| int object_size, | 
| int arena_offset, | 
| int is_default_instance_offset) { | 
| -  return new GeneratedMessageReflection(descriptor, | 
| -                                        default_instance, | 
| -                                        offsets, | 
| -                                        has_bits_offset, | 
| -                                        unknown_fields_offset, | 
| -                                        extensions_offset, | 
| -                                        default_oneof_instance, | 
| -                                        oneof_case_offset, | 
| -                                        DescriptorPool::generated_pool(), | 
| -                                        MessageFactory::generated_factory(), | 
| -                                        object_size, | 
| -                                        arena_offset, | 
| -                                        is_default_instance_offset); | 
| +  return new GeneratedMessageReflection( | 
| +      descriptor, default_instance, offsets, has_bits_offset, | 
| +      unknown_fields_offset, extensions_offset, default_oneof_instance, | 
| +      oneof_case_offset, DescriptorPool::generated_pool(), | 
| +      MessageFactory::generated_factory(), object_size, arena_offset); | 
| } | 
|  | 
| GeneratedMessageReflection* | 
| @@ -2300,17 +2290,11 @@ GeneratedMessageReflection::NewGeneratedMessageReflection( | 
| int object_size, | 
| int arena_offset, | 
| int is_default_instance_offset) { | 
| -  return new GeneratedMessageReflection(descriptor, | 
| -                                        default_instance, | 
| -                                        offsets, | 
| -                                        has_bits_offset, | 
| -                                        unknown_fields_offset, | 
| -                                        extensions_offset, | 
| -                                        DescriptorPool::generated_pool(), | 
| -                                        MessageFactory::generated_factory(), | 
| -                                        object_size, | 
| -                                        arena_offset, | 
| -                                        is_default_instance_offset); | 
| +  return new GeneratedMessageReflection( | 
| +      descriptor, default_instance, offsets, has_bits_offset, | 
| +      unknown_fields_offset, extensions_offset, | 
| +      DescriptorPool::generated_pool(), MessageFactory::generated_factory(), | 
| +      object_size, arena_offset); | 
| } | 
|  | 
| }  // namespace internal | 
|  |