diff --git a/db/dbformat.cc b/db/dbformat.cc index be48909a96..ec40bccc3a 100644 --- a/db/dbformat.cc +++ b/db/dbformat.cc @@ -44,8 +44,7 @@ std::string InternalKey::DebugString(bool hex) const { } const char* InternalKeyComparator::Name() const { - return ("leveldb.InternalKeyComparator:" + - std::string(user_comparator_->Name())).c_str(); + return name_.c_str(); } int InternalKeyComparator::Compare(const Slice& akey, const Slice& bkey) const { diff --git a/db/dbformat.h b/db/dbformat.h index 09af082e95..1a05166704 100644 --- a/db/dbformat.h +++ b/db/dbformat.h @@ -86,8 +86,13 @@ inline ValueType ExtractValueType(const Slice& internal_key) { class InternalKeyComparator : public Comparator { private: const Comparator* user_comparator_; + std::string name_; public: - explicit InternalKeyComparator(const Comparator* c) : user_comparator_(c) { } + explicit InternalKeyComparator(const Comparator* c) : user_comparator_(c), + name_("leveldb.InternalKeyComparator:" + + std::string(user_comparator_->Name())) { + } + virtual const char* Name() const; virtual int Compare(const Slice& a, const Slice& b) const; virtual void FindShortestSeparator(