bulbazord created this revision. bulbazord added reviewers: fdeazeve, kastiglione, mib, jasonmolenda. Herald added a project: All. bulbazord requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
StringRef was made to be passed by value efficiently. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D152010 Files: lldb/include/lldb/Utility/ConstString.h lldb/source/Utility/ConstString.cpp Index: lldb/source/Utility/ConstString.cpp =================================================================== --- lldb/source/Utility/ConstString.cpp +++ lldb/source/Utility/ConstString.cpp @@ -98,7 +98,7 @@ return nullptr; } - const char *GetConstCStringWithStringRef(const llvm::StringRef &string_ref) { + const char *GetConstCStringWithStringRef(const llvm::StringRef string_ref) { if (string_ref.data()) { const uint8_t h = hash(string_ref); @@ -171,7 +171,7 @@ } protected: - uint8_t hash(const llvm::StringRef &s) const { + uint8_t hash(const llvm::StringRef s) const { uint32_t h = llvm::djbHash(s); return ((h >> 24) ^ (h >> 16) ^ (h >> 8) ^ h) & 0xff; } @@ -208,7 +208,7 @@ ConstString::ConstString(const char *cstr, size_t cstr_len) : m_string(StringPool().GetConstCStringWithLength(cstr, cstr_len)) {} -ConstString::ConstString(const llvm::StringRef &s) +ConstString::ConstString(const llvm::StringRef s) : m_string(StringPool().GetConstCStringWithStringRef(s)) {} bool ConstString::operator<(ConstString rhs) const { @@ -302,8 +302,8 @@ m_string = StringPool().GetConstCString(cstr); } -void ConstString::SetString(const llvm::StringRef &s) { - m_string = StringPool().GetConstCStringWithLength(s.data(), s.size()); +void ConstString::SetString(const llvm::StringRef s) { + m_string = StringPool().GetConstCStringWithStringRef(s); } void ConstString::SetStringWithMangledCounterpart(llvm::StringRef demangled, Index: lldb/include/lldb/Utility/ConstString.h =================================================================== --- lldb/include/lldb/Utility/ConstString.h +++ lldb/include/lldb/Utility/ConstString.h @@ -43,7 +43,7 @@ /// Initializes the string to an empty string. ConstString() = default; - explicit ConstString(const llvm::StringRef &s); + explicit ConstString(const llvm::StringRef s); /// Construct with C String value /// @@ -325,7 +325,7 @@ /// A NULL terminated C string to add to the string pool. void SetCString(const char *cstr); - void SetString(const llvm::StringRef &s); + void SetString(const llvm::StringRef s); /// Set the C string value and its mangled counterpart. ///
Index: lldb/source/Utility/ConstString.cpp =================================================================== --- lldb/source/Utility/ConstString.cpp +++ lldb/source/Utility/ConstString.cpp @@ -98,7 +98,7 @@ return nullptr; } - const char *GetConstCStringWithStringRef(const llvm::StringRef &string_ref) { + const char *GetConstCStringWithStringRef(const llvm::StringRef string_ref) { if (string_ref.data()) { const uint8_t h = hash(string_ref); @@ -171,7 +171,7 @@ } protected: - uint8_t hash(const llvm::StringRef &s) const { + uint8_t hash(const llvm::StringRef s) const { uint32_t h = llvm::djbHash(s); return ((h >> 24) ^ (h >> 16) ^ (h >> 8) ^ h) & 0xff; } @@ -208,7 +208,7 @@ ConstString::ConstString(const char *cstr, size_t cstr_len) : m_string(StringPool().GetConstCStringWithLength(cstr, cstr_len)) {} -ConstString::ConstString(const llvm::StringRef &s) +ConstString::ConstString(const llvm::StringRef s) : m_string(StringPool().GetConstCStringWithStringRef(s)) {} bool ConstString::operator<(ConstString rhs) const { @@ -302,8 +302,8 @@ m_string = StringPool().GetConstCString(cstr); } -void ConstString::SetString(const llvm::StringRef &s) { - m_string = StringPool().GetConstCStringWithLength(s.data(), s.size()); +void ConstString::SetString(const llvm::StringRef s) { + m_string = StringPool().GetConstCStringWithStringRef(s); } void ConstString::SetStringWithMangledCounterpart(llvm::StringRef demangled, Index: lldb/include/lldb/Utility/ConstString.h =================================================================== --- lldb/include/lldb/Utility/ConstString.h +++ lldb/include/lldb/Utility/ConstString.h @@ -43,7 +43,7 @@ /// Initializes the string to an empty string. ConstString() = default; - explicit ConstString(const llvm::StringRef &s); + explicit ConstString(const llvm::StringRef s); /// Construct with C String value /// @@ -325,7 +325,7 @@ /// A NULL terminated C string to add to the string pool. void SetCString(const char *cstr); - void SetString(const llvm::StringRef &s); + void SetString(const llvm::StringRef s); /// Set the C string value and its mangled counterpart. ///
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits