[cfe-commits] r48532 - /cfe/trunk/include/clang/Rewrite/Rewriter.h
Chris Lattner
clattner at apple.com
Tue Mar 18 22:37:57 PDT 2008
On Mar 18, 2008, at 10:06 PM, Ted Kremenek wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=48532&view=rev
> Log:
> Added InsertStrXXX/InsertCStrXXX methods to the Rewriter to provide
> a simpler
> interface to the rewriter when clients have NULL terminated strings
> or std::string.
Nice.
> + bool InsertStrBefore(SourceLocation Loc, const std::string& S) {
> + return InsertTextBefore(Loc, S.c_str(), S.size());
> + }
I'd suggest using:
if (S.empty()) return false;
return InsertTextBefore(Loc, &S[0], S.size());
because c_str() has to add a nul terminator to the string, which is
potentially expensive (causes a COW in some implementations).
-Chris
>
> +
> + bool InsertStrAfter(SourceLocation Loc, const std::string& S) {
> + return InsertTextAfter(Loc, S.c_str(), S.size());
> + }
> +
>
> /// RemoveText - Remove the specified text region.
> bool RemoveText(SourceLocation Start, unsigned Length);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list