diff options
Diffstat (limited to 'src/google/protobuf/descriptor.cc')
-rw-r--r-- | src/google/protobuf/descriptor.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index fc3a9c77..fd003994 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -406,9 +406,10 @@ typedef std::pair<const EnumDescriptor*, int> EnumIntPair; template<typename PairType> struct PointerIntegerPairHash { size_t operator()(const PairType& p) const { - // FIXME(kenton): What is the best way to compute this hash? I have - // no idea! This seems a bit better than an XOR. - return reinterpret_cast<intptr_t>(p.first) * ((1 << 16) - 1) + p.second; + static const size_t prime1 = 16777499; + static const size_t prime2 = 16777619; + return reinterpret_cast<size_t>(p.first) * prime1 ^ + static_cast<size_t>(p.second) * prime2; } #ifdef _MSC_VER @@ -424,11 +425,10 @@ struct PointerIntegerPairHash { struct PointerStringPairHash { size_t operator()(const PointerStringPair& p) const { - // FIXME(kenton): What is the best way to compute this hash? I have - // no idea! This seems a bit better than an XOR. + static const size_t prime = 16777619; hash<const char*> cstring_hash; - return reinterpret_cast<intptr_t>(p.first) * ((1 << 16) - 1) + - cstring_hash(p.second); + return reinterpret_cast<size_t>(p.first) * prime ^ + static_cast<size_t>(cstring_hash(p.second)); } #ifdef _MSC_VER @@ -6906,7 +6906,7 @@ class DescriptorBuilder::OptionInterpreter::AggregateOptionFinder DescriptorBuilder* builder_; virtual const FieldDescriptor* FindExtension( - Message* message, const string& name) const { + Message* message, const string& name) const override { assert_mutex_held(builder_->pool_); const Descriptor* descriptor = message->GetDescriptor(); Symbol result = builder_->LookupSymbolNoPlaceholder( @@ -6944,7 +6944,7 @@ class AggregateErrorCollector : public io::ErrorCollector { string error_; virtual void AddError(int /* line */, int /* column */, - const string& message) { + const string& message) override { if (!error_.empty()) { error_ += "; "; } @@ -6952,7 +6952,7 @@ class AggregateErrorCollector : public io::ErrorCollector { } virtual void AddWarning(int /* line */, int /* column */, - const string& /* message */) { + const string& /* message */) override { // Ignore warnings } }; |