[Lldb-commits] [lldb] r358357 - Prevent unnecessary conversion from StringRef to C-string [NFC]

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Sun Apr 14 07:01:50 PDT 2019


Author: teemperor
Date: Sun Apr 14 07:01:49 2019
New Revision: 358357

URL: http://llvm.org/viewvc/llvm-project?rev=358357&view=rev
Log:
Prevent unnecessary conversion from StringRef to C-string [NFC]

There is an alternative method to GetConstCStringWithLength that
takes a StringRef. GetConstCStringWithLength also calls this
method in the end, so directly calling the StringRef saves
us from a unnecessary conversion to a C-string.

Modified:
    lldb/trunk/source/Utility/ConstString.cpp

Modified: lldb/trunk/source/Utility/ConstString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ConstString.cpp?rev=358357&r1=358356&r2=358357&view=diff
==============================================================================
--- lldb/trunk/source/Utility/ConstString.cpp (original)
+++ lldb/trunk/source/Utility/ConstString.cpp Sun Apr 14 07:01:49 2019
@@ -200,7 +200,7 @@ ConstString::ConstString(const char *cst
     : m_string(StringPool().GetConstCStringWithLength(cstr, cstr_len)) {}
 
 ConstString::ConstString(const llvm::StringRef &s)
-    : m_string(StringPool().GetConstCStringWithLength(s.data(), s.size())) {}
+    : m_string(StringPool().GetConstCStringWithStringRef(s)) {}
 
 bool ConstString::operator<(ConstString rhs) const {
   if (m_string == rhs.m_string)




More information about the lldb-commits mailing list