<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Yes, this isn't something that should be in StringRef, I would go so far to say this is an invariant clients can rely on:<div>--</div><div>StringRef(a).data() == a</div><div>--</div><div><br></div><div>As Chris mentions we want the StringRef constructors to be simple, we use them a lot and rely on the optimizer to clean them up, for example in default arguments. It's good to avoid any unnecessary complexity.</div><div><br></div><div> - Daniel<br><div><br><div><div>On Sep 29, 2009, at 9:59 PM, Chris Lattner wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Sep 29, 2009, at 11:57 AM, Devang Patel wrote:</div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Sep 29, 2009, at 11:53 AM, Chris Lattner wrote:</div><blockquote type="cite"><div>On Sep 29, 2009, at 11:39 AM, Devang Patel wrote:<br>Author: dpatel<br><blockquote type="cite">Date: Tue Sep 29 13:39:56 2009<br></blockquote><blockquote type="cite">New Revision: 83082<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=83082&view=rev">http://llvm.org/viewvc/llvm-project?rev=83082&view=rev</a><br></blockquote><blockquote type="cite">Log:<br></blockquote><blockquote type="cite">Create empty StringRef is incoming cstring is NULL.<br></blockquote><br>I don't think this is correct, StringRef shouldn't allow null cstrings to be passed in.<font class="Apple-style-span"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><br></div><div>I'm using it to pass optional strings. For example, linkage name in debug info. </div><div>Note, one can create empty StringRef by say</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>SringRef foo;</div><div>If this is not desirable then I'll update DebugInfo interface.</div></div></blockquote></div><br><div>The reason I mention that is that stringref is frequently used for const char*'s, and this adds an extra branch to the common case.  Doing something like:</div><div><br></div><div>  return ptr != 0 : StringRef(ptr) : StringRef();</div><div><br></div><div>in the debug info stuff would make it pay the cost locally instead of making all clients of stringref pay it.</div><div><br></div><div>What do you think Daniel?</div><div><br></div><div>BTW, getting rid of std::string from debug info is really really awesome!</div><div><br></div><div>-Chris</div><div><br></div></div></blockquote></div><br></div></div></body></html>