Skip to content

Commit 5fdfa83

Browse files
committed
[NFC][LLVM][ADT] Change a few const StringRef & arguments to value
Per LLVM Programmer's Manual, StringRef should always be passed by value. Enforcing this for a few ADT functions.
1 parent a55c4c8 commit 5fdfa83

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

llvm/include/llvm/ADT/STLExtras.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,13 +2215,12 @@ inline void interleave(const Container &c, UnaryFunctor each_fn,
22152215
template <typename Container, typename UnaryFunctor, typename StreamT,
22162216
typename T = detail::ValueOfRange<Container>>
22172217
inline void interleave(const Container &c, StreamT &os, UnaryFunctor each_fn,
2218-
const StringRef &separator) {
2218+
StringRef separator) {
22192219
interleave(adl_begin(c), adl_end(c), each_fn, [&] { os << separator; });
22202220
}
22212221
template <typename Container, typename StreamT,
22222222
typename T = detail::ValueOfRange<Container>>
2223-
inline void interleave(const Container &c, StreamT &os,
2224-
const StringRef &separator) {
2223+
inline void interleave(const Container &c, StreamT &os, StringRef separator) {
22252224
interleave(
22262225
c, os, [&](const T &a) { os << a; }, separator);
22272226
}

llvm/include/llvm/ADT/Twine.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class Twine {
285285
}
286286

287287
/// Construct from a StringRef.
288-
/*implicit*/ Twine(const StringRef &Str) : LHSKind(PtrAndLengthKind) {
288+
/*implicit*/ Twine(StringRef Str) : LHSKind(PtrAndLengthKind) {
289289
LHS.ptrAndLength.ptr = Str.data();
290290
LHS.ptrAndLength.length = Str.size();
291291
assert(isValid() && "Invalid twine!");
@@ -352,7 +352,7 @@ class Twine {
352352
// right thing. Yet.
353353

354354
/// Construct as the concatenation of a C string and a StringRef.
355-
/*implicit*/ Twine(const char *LHS, const StringRef &RHS)
355+
/*implicit*/ Twine(const char *LHS, StringRef RHS)
356356
: LHSKind(CStringKind), RHSKind(PtrAndLengthKind) {
357357
this->LHS.cString = LHS;
358358
this->RHS.ptrAndLength.ptr = RHS.data();
@@ -361,7 +361,7 @@ class Twine {
361361
}
362362

363363
/// Construct as the concatenation of a StringRef and a C string.
364-
/*implicit*/ Twine(const StringRef &LHS, const char *RHS)
364+
/*implicit*/ Twine(StringRef LHS, const char *RHS)
365365
: LHSKind(PtrAndLengthKind), RHSKind(CStringKind) {
366366
this->LHS.ptrAndLength.ptr = LHS.data();
367367
this->LHS.ptrAndLength.length = LHS.size();
@@ -530,14 +530,14 @@ inline Twine operator+(const Twine &LHS, const Twine &RHS) {
530530
/// Additional overload to guarantee simplified codegen; this is equivalent to
531531
/// concat().
532532

533-
inline Twine operator+(const char *LHS, const StringRef &RHS) {
533+
inline Twine operator+(const char *LHS, StringRef RHS) {
534534
return Twine(LHS, RHS);
535535
}
536536

537537
/// Additional overload to guarantee simplified codegen; this is equivalent to
538538
/// concat().
539539

540-
inline Twine operator+(const StringRef &LHS, const char *RHS) {
540+
inline Twine operator+(StringRef LHS, const char *RHS) {
541541
return Twine(LHS, RHS);
542542
}
543543

0 commit comments

Comments
 (0)