[Lldb-commits] [PATCH] D152010: [lldb][NFCI] ConstString methods should take StringRefs by value

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 2 10:43:29 PDT 2023


bulbazord updated this revision to Diff 527908.
bulbazord added a comment.

Remove `const` where unneeded.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152010/new/

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(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(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(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(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(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(llvm::StringRef s);
 
   /// Set the C string value and its mangled counterpart.
   ///


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152010.527908.patch
Type: text/x-patch
Size: 2192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230602/266afbdf/attachment.bin>


More information about the lldb-commits mailing list