Use .data() instead of .c_str() when nul-termination is not needed.
authorDan Gohman <gohman@apple.com>
Fri, 13 Nov 2009 21:55:31 +0000 (21:55 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 13 Nov 2009 21:55:31 +0000 (21:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88703 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringRef.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp

index 6b17eb22de7902d9d7a747031efd8e0433e3c9d9..b6486e7676348ce0a5e0718a8a114f750ea8ec72 100644 (file)
@@ -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
index 9bac86001348276e327e828bfc917a329e3f1861..7c5c23b268ff2b9f6c63801967a78c608b0f3122 100644 (file)
@@ -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 {