[PATCH] D129533: [ADT] Pass string_view via copy

ppenguin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 11 19:12:22 PDT 2022


prehistoric-penguin created this revision.
Herald added a project: All.
prehistoric-penguin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129533

Files:
  llvm/include/llvm/ADT/Twine.h


Index: llvm/include/llvm/ADT/Twine.h
===================================================================
--- llvm/include/llvm/ADT/Twine.h
+++ llvm/include/llvm/ADT/Twine.h
@@ -292,8 +292,7 @@
     /// length.  This handles string_views on a pure API basis, and avoids
     /// storing one (or a pointer to one) inside a Twine, which avoids problems
     /// when mixing code compiled under various C++ standards.
-    /*implicit*/ Twine(const std::string_view &Str)
-        : LHSKind(PtrAndLengthKind) {
+    /*implicit*/ Twine(std::string_view Str) : LHSKind(PtrAndLengthKind) {
       LHS.ptrAndLength.ptr = Str.data();
       LHS.ptrAndLength.length = Str.length();
       assert(isValid() && "Invalid twine!");
@@ -301,7 +300,7 @@
 #endif
 
     /// Construct from a StringRef.
-    /*implicit*/ Twine(const StringRef &Str) : LHSKind(PtrAndLengthKind) {
+    /*implicit*/ Twine(StringRef Str) : LHSKind(PtrAndLengthKind) {
       LHS.ptrAndLength.ptr = Str.data();
       LHS.ptrAndLength.length = Str.size();
       assert(isValid() && "Invalid twine!");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129533.443814.patch
Type: text/x-patch
Size: 1062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220712/52dbab2d/attachment.bin>


More information about the llvm-commits mailing list