[cfe-commits] r84378 - /cfe/trunk/lib/Parse/ParseInit.cpp
Daniel Dunbar
daniel at zuster.org
Sat Oct 17 16:52:50 PDT 2009
Author: ddunbar
Date: Sat Oct 17 18:52:50 2009
New Revision: 84378
URL: http://llvm.org/viewvc/llvm-project?rev=84378&view=rev
Log:
Avoid std::string concatenation.
Modified:
cfe/trunk/lib/Parse/ParseInit.cpp
Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=84378&r1=84377&r2=84378&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Sat Oct 17 18:52:50 2009
@@ -15,6 +15,7 @@
#include "clang/Parse/Parser.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/raw_ostream.h"
using namespace clang;
@@ -65,9 +66,9 @@
if (Tok.is(tok::identifier)) {
const IdentifierInfo *FieldName = Tok.getIdentifierInfo();
- std::string NewSyntax(".");
- NewSyntax += FieldName->getName();
- NewSyntax += " = ";
+ llvm::SmallString<256> NewSyntax;
+ llvm::raw_svector_ostream(NewSyntax) << '.' << FieldName->getNameStr()
+ << " = ";
SourceLocation NameLoc = ConsumeToken(); // Eat the identifier.
@@ -77,7 +78,7 @@
Diag(Tok, diag::ext_gnu_old_style_field_designator)
<< CodeModificationHint::CreateReplacement(SourceRange(NameLoc,
ColonLoc),
- NewSyntax);
+ NewSyntax.str());
Designation D;
D.AddDesignator(Designator::getField(FieldName, SourceLocation(), NameLoc));
More information about the cfe-commits
mailing list