<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 25, 2016 at 9:59 AM, Etienne Bergeron via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">etienneb created this revision.<br>
etienneb added a subscriber: cfe-commits.<br>
<br>
The string class contains methods which support receiving either a string literal or a string object.<br>
<br>
For example, calls to append can receive either a char* or a string.<br>
```<br>
  string& append (const string& str);<br>
  string& append (const char* s);<br>
```<br>
<br>
Which make these cases equivalent, and the .c_str() useless:<br>
```<br>
  std::string s = "123";<br>
  str.append(s);<br>
  str.append(s.c_str());<br>
```<br>
<br>
In these cases, removing .c_str()  doesn't provide any size or speed improvement.<br>
It's only a readability issue.<br></blockquote><div><br></div><div>potential speed improvement by not having to search for the null terminator</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If the string contains embedded NUL characters,  the string literal and the string<br>
object won't produce the same semantic.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D18475" rel="noreferrer" target="_blank">http://reviews.llvm.org/D18475</a><br>
<br>
Files:<br>
  clang-tidy/readability/RedundantStringCStrCheck.cpp<br>
  test/clang-tidy/readability-redundant-string-cstr.cpp<br>
<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>