[Lldb-commits] [lldb] ccdb5b4 - [lldb] Pass ConstString by value (again) (NFC)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 23 09:08:39 PDT 2020
Author: Jonas Devlieghere
Date: 2020-07-23T09:08:32-07:00
New Revision: ccdb5b4bbe8470d1c558ecfd0658240d4c8f8df2
URL: https://github.com/llvm/llvm-project/commit/ccdb5b4bbe8470d1c558ecfd0658240d4c8f8df2
DIFF: https://github.com/llvm/llvm-project/commit/ccdb5b4bbe8470d1c558ecfd0658240d4c8f8df2.diff
LOG: [lldb] Pass ConstString by value (again) (NFC)
This reverts "Eliminate unneeded value parameters in Utility" for
ConstString. As Pavel pointed out on the mailing list, the class *is*
trivially copyable.
Added:
Modified:
lldb/include/lldb/Utility/ConstString.h
lldb/source/Utility/ConstString.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h
index 459e6dcc960a..5f4d747734ec 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -133,7 +133,7 @@ class ConstString {
///
/// \return
/// A const reference to this object.
- ConstString operator=(const ConstString &rhs) {
+ ConstString operator=(ConstString rhs) {
m_string = rhs.m_string;
return *this;
}
@@ -150,7 +150,7 @@ class ConstString {
/// \return
/// true if this object is equal to \a rhs.
/// false if this object is not equal to \a rhs.
- bool operator==(const ConstString &rhs) const {
+ bool operator==(ConstString rhs) const {
// We can do a pointer compare to compare these strings since they must
// come from the same pool in order to be equal.
return m_string == rhs.m_string;
@@ -192,9 +192,7 @@ class ConstString {
/// \return
/// \b true if this object is not equal to \a rhs.
/// \b false if this object is equal to \a rhs.
- bool operator!=(const ConstString &rhs) const {
- return m_string != rhs.m_string;
- }
+ bool operator!=(ConstString rhs) const { return m_string != rhs.m_string; }
/// Not equal to operator against a non-ConstString value.
///
@@ -209,7 +207,7 @@ class ConstString {
/// \return \b true if this object is not equal to \a rhs, false otherwise.
bool operator!=(const char *rhs) const { return !(*this == rhs); }
- bool operator<(const ConstString &rhs) const;
+ bool operator<(ConstString rhs) const;
/// Get the string value as a C string.
///
@@ -279,7 +277,7 @@ class ConstString {
/// will be tested, otherwise character case will be ignored
///
/// \return \b true if this object is equal to \a rhs, \b false otherwise.
- static bool Equals(const ConstString &lhs, const ConstString &rhs,
+ static bool Equals(ConstString lhs, ConstString rhs,
const bool case_sensitive = true);
/// Compare two string objects.
@@ -303,7 +301,7 @@ class ConstString {
/// will be performed, otherwise character case will be ignored
///
/// \return -1 if lhs < rhs, 0 if lhs == rhs, 1 if lhs > rhs
- static int Compare(const ConstString &lhs, const ConstString &rhs,
+ static int Compare(ConstString lhs, ConstString rhs,
const bool case_sensitive = true);
/// Dump the object description to a stream.
@@ -371,7 +369,7 @@ class ConstString {
/// The already uniqued mangled ConstString to correlate the
/// soon to be uniqued version of \a demangled.
void SetStringWithMangledCounterpart(llvm::StringRef demangled,
- const ConstString &mangled);
+ ConstString mangled);
/// Retrieve the mangled or demangled counterpart for a mangled or demangled
/// ConstString.
@@ -452,7 +450,7 @@ class ConstString {
};
/// Stream the string value \a str to the stream \a s
-Stream &operator<<(Stream &s, const ConstString &str);
+Stream &operator<<(Stream &s, ConstString str);
} // namespace lldb_private
@@ -473,11 +471,11 @@ template <> struct DenseMapInfo<lldb_private::ConstString> {
return lldb_private::ConstString::FromStringPoolPointer(
DenseMapInfo<const char *>::getTombstoneKey());
}
- static unsigned getHashValue(const lldb_private::ConstString &val) {
+ static unsigned getHashValue(lldb_private::ConstString val) {
return DenseMapInfo<const char *>::getHashValue(val.m_string);
}
- static bool isEqual(const lldb_private::ConstString &LHS,
- const lldb_private::ConstString &RHS) {
+ static bool isEqual(lldb_private::ConstString LHS,
+ lldb_private::ConstString RHS) {
return LHS == RHS;
}
};
@@ -491,8 +489,7 @@ template <> struct ScalarTraits<lldb_private::ConstString> {
};
} // namespace yaml
-inline raw_ostream &operator<<(raw_ostream &os,
- const lldb_private::ConstString &s) {
+inline raw_ostream &operator<<(raw_ostream &os, lldb_private::ConstString s) {
os << s.GetStringRef();
return os;
}
diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp
index 2a9272ce84da..11f48d0fcaba 100644
--- a/lldb/source/Utility/ConstString.cpp
+++ b/lldb/source/Utility/ConstString.cpp
@@ -212,7 +212,7 @@ ConstString::ConstString(const char *cstr, size_t cstr_len)
ConstString::ConstString(const llvm::StringRef &s)
: m_string(StringPool().GetConstCStringWithStringRef(s)) {}
-bool ConstString::operator<(const ConstString &rhs) const {
+bool ConstString::operator<(ConstString rhs) const {
if (m_string == rhs.m_string)
return false;
@@ -227,7 +227,7 @@ bool ConstString::operator<(const ConstString &rhs) const {
return lhs_string_ref.data() == nullptr;
}
-Stream &lldb_private::operator<<(Stream &s, const ConstString &str) {
+Stream &lldb_private::operator<<(Stream &s, ConstString str) {
const char *cstr = str.GetCString();
if (cstr != nullptr)
s << cstr;
@@ -239,7 +239,7 @@ size_t ConstString::GetLength() const {
return Pool::GetConstCStringLength(m_string);
}
-bool ConstString::Equals(const ConstString &lhs, const ConstString &rhs,
+bool ConstString::Equals(ConstString lhs, ConstString rhs,
const bool case_sensitive) {
if (lhs.m_string == rhs.m_string)
return true;
@@ -256,7 +256,7 @@ bool ConstString::Equals(const ConstString &lhs, const ConstString &rhs,
return lhs_string_ref.equals_lower(rhs_string_ref);
}
-int ConstString::Compare(const ConstString &lhs, const ConstString &rhs,
+int ConstString::Compare(ConstString lhs, ConstString rhs,
const bool case_sensitive) {
// If the iterators are the same, this is the same string
const char *lhs_cstr = lhs.m_string;
@@ -308,7 +308,7 @@ void ConstString::SetString(const llvm::StringRef &s) {
}
void ConstString::SetStringWithMangledCounterpart(llvm::StringRef demangled,
- const ConstString &mangled) {
+ ConstString mangled) {
m_string = StringPool().GetConstCStringAndSetMangledCounterPart(
demangled, mangled.m_string);
}
More information about the lldb-commits
mailing list