From cfca06d7963fa0909f90483b42a6d7d194d01e08 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 26 Jul 2020 19:36:28 +0000 Subject: Vendor import of llvm-project master 2e10b7a39b9, the last commit before the llvmorg-12-init tag, from which release/11.x was branched. --- llvm/lib/Support/StringRef.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'llvm/lib/Support/StringRef.cpp') diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp index 104482de4ad70..ab67ef9ce85c1 100644 --- a/llvm/lib/Support/StringRef.cpp +++ b/llvm/lib/Support/StringRef.cpp @@ -19,7 +19,7 @@ using namespace llvm; // MSVC emits references to this into the translation units which reference it. #ifndef _MSC_VER -const size_t StringRef::npos; +constexpr size_t StringRef::npos; #endif // strncasecmp() is not available on non-POSIX systems, so define an @@ -106,19 +106,13 @@ unsigned StringRef::edit_distance(llvm::StringRef Other, //===----------------------------------------------------------------------===// std::string StringRef::lower() const { - std::string Result(size(), char()); - for (size_type i = 0, e = size(); i != e; ++i) { - Result[i] = toLower(Data[i]); - } - return Result; + return std::string(map_iterator(begin(), toLower), + map_iterator(end(), toLower)); } std::string StringRef::upper() const { - std::string Result(size(), char()); - for (size_type i = 0, e = size(); i != e; ++i) { - Result[i] = toUpper(Data[i]); - } - return Result; + return std::string(map_iterator(begin(), toUpper), + map_iterator(end(), toUpper)); } //===----------------------------------------------------------------------===// -- cgit v1.2.3