From 24f8e29b4efe70496474c6d43aa6abfa27c21511 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 13 Nov 2009 21:55:31 +0000 Subject: [PATCH] Use .data() instead of .c_str() when nul-termination is not needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88703 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/StringRef.h | 2 +- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 6b17eb22de7..b6486e76763 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -56,7 +56,7 @@ namespace llvm { /// Construct a string ref from an std::string. /*implicit*/ StringRef(const std::string &Str) - : Data(Str.c_str()), Length(Str.length()) {} + : Data(Str.data()), Length(Str.length()) {} /// @} /// @name Iterators diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 9bac8600134..7c5c23b268f 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -729,7 +729,7 @@ static void printStringChar(formatted_raw_ostream &O, unsigned char C) { /// Special characters are emitted properly. /// \literal (Eg. '\t') \endliteral void AsmPrinter::EmitString(const std::string &String) const { - EmitString(String.c_str(), String.size()); + EmitString(String.data(), String.size()); } void AsmPrinter::EmitString(const char *String, unsigned Size) const {